Multiuser message size notes
When making a multiuser movie, it's important to consider the size of the messages being sent between systems. This TechNote describes how to roughly calculate the number of bytes in each message.
Knowing the size of messages being sent and received by your movie can help prevent bottlenecks. You might consider, for example, sending messages less frequently or broadcasting data together to lower network traffic.
In general, fewer large messages work much better than more small messages. This is both due to decreased network overhead (less message header data being sent) and fewer messages to process in your lingo code.
Each message consists of the error code, server time stamp, subject, sender, recipient list and contents. There is also some additional message formatting information. To get the message size, total all the components of the message and add another 16 bytes or so.
The table below lists some quick guidelines for the size of content values and is followed by an example.
| Integers | 4 bytes |
| Floats |
8 bytes |
| Strings | the number of characters, rounded up to an even number, plus 4 |
| Symbols | the text representation size (when it looks like a string) |
| Lists | total of all the elements, plus 4 |
| Properties | symbol size plus the value size |
| Points | the total of the size of the two numbers, floats or integers |
| Rects | the total of the size of the four numbers, floats or integers |
| Media or
Picture of member |
actual memory resident size of the object in Director |
Example of a chat message
| Header data | 16 | |
| #errorCode | 0 | 4 |
| #timeStamp | 123456 | 4 |
| #subject | "ChatMsg" | 12 |
| #sender | "Myname" | 10 |
| #recipient | "@ChatGroup" | 14 |
| #content | "What is the weather like ?" | 30 |
| Total number of bytes |
90 |
To look at the message traffic on the server, you must consider how large the messages are, how often they are sent, and how they are distributed from the server.
The formula for the byte rate passing the server is:
msgRate = Rate of messages, in messages per second, per movie bytesPerMsg = Number of bytes per message groupSize = Group size the message is being distributed to numUsers = Total number of users connected to the movie Total bytes/second at the server = numUsers * msgRate * bytesPerMsg * (groupSize + 1)
The"+ 1" in the formula takes in account that the message is sent to the server and then redistributed to all the members in the group.
For our chat example, let's assume each user sends out a message every 20 seconds. The chat messages look like the one above, about 100 bytes each. Assume there is an average of 8 people in each chat group, and 65 people logged on total. That gives a traffic rate at the server of:
65 * 1/20 * 100 * (8 + 1) = 2925 bytes per second
At the client end, the formula for messages traffic is:
Total bytes/second at the client = (groupSize + 1) * msgRate * bytesPerMsg.
The"+1" in the formula takes into account that messages sent to the server are relayed and sent back to the same client.
In our above example, this means the data rate is:
(8 + 1) * 1/20 * 100 = 45 bytes per second.
For both cases, the data will not be a steady flow. The flow will be in somewhat random patterns. There will be peaks and lows in the data rate, raising and lowering the amount of information passing through the data pipe.
This content requires Flash
To view this content, JavaScript must be enabled, and you need the latest version of the Adobe Flash Player.
Download the free Flash Player now!
