Multiplayer game server: How much is too much communication from the client to the server

1.1k views Asked by At

I am making a multiplayer game (server/client) with unity and a Colyseus backend. Currently the backend sends 20 updates per second to each client. I want each client to also send approximately 20 messages to the server each second. Is this too much communication? (the messages are very small, a JSON object with 5 string fields).

I don't want to build the game and find out it is not scalable :(. So Thesis: is Each client sending a small message to the server 20 times a second too much?

2

There are 2 answers

0
Slugart On

This depends on many things that you haven't specified, first among those is how many simultaneous and how many server isntances players you expect to have.

I would recommend you quickly benchmark how long the (de)serialisation of your message takes and then multiply it by the actual message volume you expect to see.

You could also create a proof of concept that does nothing except send messages at different messages rates to see yourself how it would scale.

0
Pavlović Dž Filip On

As mentioned by Slugart, it is best to benchmark and go from there.

That being said, there are a few things you can do if you find the performance to be a bottleneck:

  • Lower the number of messages - generally, 20 messages per second per client might be a bit too much - games usually go with less than half of that (6-12 msg/s).
  • Use binary format instead of json - if the server needs to act as a relay, you could encode your messages using binary protocol. Look into protobuf or messagepack.

There are some other options available, but they are not available for javascript (as far as I know). In case you are expecting a large number of players, and every want to optimize as much as possible, I would suggest switching to a backend that supports multithreading, object pooling (to reduce Garbage Collection time), etc, to gain the most performance.

Disclaimer: I am a co-founder of ServerBytes - we help you make games faster.

You can also try ServerBytes for free - a platform which supports high concurrency, high throughput, custom c# backend code and more.