1
\$\begingroup\$

(note: I'm not asking for the supported formats in the RFC, but the format I should develop to send/receive the messages, say, in the Application layer).

(note 2: Please help me retagging this post to reference internet, communication, client-server messages).

I am developing a game. Right now it is just a concept of a multiplayer game, tile-mapped, with role-playing characters.

The big problem here? It will be online-massive. My concerns are about lag and transmission. The front-end will be pure ActionScript3. The connection will be done with websockets.

Certain actions will be really quick like: walk, grab (item) and perhaps hit (attack) or execute another type of quick action (e.g. use a small, quick, item).

Considering that websockets are not plain sockets, and this is my first online game, my question is about the protocol to use.

Right now, I marshall the messages in the following format (this is just an example, since I did not develop the actual commands yet):

client ---> {'code': 'walk', 'kwargs': {'direction': 'left'}} ---> server
server ---> {'code': 'walk.ok', 'kwargs': {}} ---> client

As you can see, it is JSON format, sent via websockets. The processing backend is Tornado with Python 2.7. I developed a library to marshal and unmarshal these messages.

Assuming that, as an expected peak (with so much luck), I will have 1000 players mostly walking... will I have performance issues with this protocol I defined? Actually, I'm asking about

I want to avoid lag as much as possible, considering websocket transmission.

What format is more adecquate and performant for MMORPG games client-server communication for these really-quick actions? Actually I never developed one of these games and I'm concerned about the performance.

\$\endgroup\$
4
  • 1
    \$\begingroup\$ To use as little bandwidth as possible, online games typically communicate in binary rather than text. The highest performance solutions generally use some type of entropy coding to make these communications as lean as possible - see the "Networking" articles here for some ideas: number-none.com/product So the question is: are you interested in bandwidth-frugal but relatively complex techniques like this, or would you prefer the human legibility of text key-value pairs as you describe above? \$\endgroup\$
    – DMGregory
    Apr 29 '15 at 17:22
  • \$\begingroup\$ Thanks for the link!! I will look and learan how to balance the communications and perhaps develop a debugging tool if I choose a binary format. But ¿what will hit worse in the JSON format?¿the message marshalling/unmarshalling or the used bandwidth? (for 1000 players) \$\endgroup\$ Apr 29 '15 at 17:32
  • \$\begingroup\$ I wonder if you meant multiplayer RPG when you wrote MMORPG. If you really mean MMO, you're already in way over your head, because this is a very basic multiplayer scenario. See also: gamedev.net/blog/355/… and gamedev.stackexchange.com/questions/90/… \$\endgroup\$
    – jzx
    Apr 29 '15 at 18:31
  • \$\begingroup\$ Yes: Multiplayer Massive Online RPG (Argentum Online, WoW, Lineage, Ultima Online, Ragnarok Online, ... you get the idea). Multiple characters moving at same time. I cannot create the tag "mmorpg", have not enough rep. \$\endgroup\$ Apr 29 '15 at 19:43
2
\$\begingroup\$

With all respect: Don't worry about it... yet.

By all means, keep in mind that eventually, to run at scale with as few servers as possible, you may need to use a binary format.

You will probably benefit from omitting duplicate data; there's no need for sending "Still moving at velocity 1.0, no change there!" hundreds of times a second.

You will certainly need to resolve issues relating to timing of nodes with different ping times, lost and found connections, sanity-synchs from time to time, and many other things.

Switching from JSON to binary, if and when the time comes, will involve swapping out one well-defined part of your code. (Or possibly keeping both, and checking if the first character of a message is '{' to decide which flavor.)

In the early stages, having text-based easy-to-read messages will be more valuable. It will ease your debugging, and you can use ready-made solutions to get on with it. Done!

Because... You have hundreds of hours of more interesting problems to solve before worrying about 1000 low-bandwidth players.

(On the other hand, if you're not actually writing a game, and just want to learn about data compression for networking, that would change your priorities.)

\$\endgroup\$
1
  • 1
    \$\begingroup\$ This is about the experience I made with my last project which was also an MMO with websockets. JSON has the advantage that it is human-readable, easy to manually create messages and makes it easy to introduce new features without breaking the old. You can dump network I/O directly to the console and get plenty of useful debugging output. But when the main development phase is over and you proceed to the maintainance phase, switching to a binary protocol can save lots of bandwidth. \$\endgroup\$
    – Philipp
    Apr 30 '15 at 13:33

Not the answer you're looking for? Browse other questions tagged .