I just read on nakamas documentation that a MTU should not exceed 1500 bytes. The problem that i have is that I am currently building an open world mutliplayer game, and this is divided into chunks. So the way I am dealing with this now is that if a player enters a new chunk, Iupdate the player with the players/entities etc inside the new chunk. Therefor i can easily exceed 1500 bytes.
At the moment, sending 8 entities to the player is roughly 2k bytes. Dependent on what information each entity holds. Im currently only sending the data that is needed.
I assume len(byte) gives me the correct length of bytes
So my question is: What am i suppose to do here? Each chunk will definitely have more than 8 entities. Is it ok to send up to 8k of bytes to update the player with information of the new chunk? Or am i a lost case?
EDIT: Example of a single entity response. When updaing multiple, these are given as an array.
@gruset The MTU-based recommendation is a best practice approach to ensuring fast and timely delivery of data. It’s not a hard and fast rule for every single message. In fact it’s common to have larger initial sync messages as you’ve discovered - since until synced the client is not ready to be a useful actor in your system, so the absolute speed of quick message exchanges can be lower priority until sync is complete.
That said you can do a few things to improve this:
- Use a binary message encoding, not JSON.
- If that’s not possible/desirable, at least use shorter JSON keys. You can probably get that entity JSON down to almost half its current size.
- Send the initial sync data in batches, 10 entities at a time or whatever unit is best for you. You can include remaining entity counts with each message to help the client figure out when sync is complete or even indicate progress to the user.
This last one is most useful to you I think, and would ensure the system remains “responsive” to the client for other messages that can be interleaved with the sync process.
Hey @zyro and thank you for the reply!
I will absolutely try to send the entities in batches. Might be worth to increased number of serialize operation on the server for smaller messages! Ill try to shorten then keys as well!