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.
@zyro I recently run a few tests in my game and i ran into the problem with too big messages being sent. I knew this would be a problem, so now I’m trying to send the states in batches as you suggested. What is the preferred way to send messages in batches? Send all the batches in one tick or split them up in several server updates?
I’m getting some weird behavior while sending them all in one for-loop on the same tick that i have to do some investigation to figure out.