How does Ably measure message size?

The message size for limits and pricing is considered to be the sum of the sizes of all of the parts of a message that are under control of the client, including name, clientId, and data, before any compression (or expansion) that occurs in the serialization process. The size in bytes is calculated as the sum of the size in bytes of the utf8 representation of name and clientId, plus the size of the data (which is either its size, if it is binary, or its utf8 byte length if it is a string).

If the data is binary and the message is sent on a text transport and therefore has base64-encoded data in the data  attribute, and has an encoding  attribute of base64, the size limit applied is the actual size of the binary data, not the size of the base64-encoded string.

Note that if you are using the `publish(Array<Message>)` form to publish an array of messages, the message size limit applies to the sum of all messages in the array. As the messages in the array are published and broadcast atomically, they are treated as a single unit by our servers; the ability to represent them as into multiple separate messages is just a convenience.