I'm trying to develop a small web game using Spring Websockets. I am unsure of what the best method of sending game data updates to the client is.
Is it better to send all of the data in a bulk update at the end of each game update or is it better to send individual packets of data constantly as each object in the game is updated?
I asked this question a week or 2 ago and got no response so I went ahead and created a test game and made 3 branches of the project to test this.
Short Answer: Bulk updates are much faster when working with Spring Websockets.
The first branch I created was the "Packet Spread" branch. It sent data to the clients about each object in the game world as it looped through them and updated their attributes during a game tick.
The second branch I created was the "Packet Blob" branch. It collected all the data that was updated over a game tick and sent it in 1 bulk update at the end of the game tick.
I also created a third branch called "Packet Spread Threaded" which worked the same as the original Packet Spread branch except it passed all the game data to a separate thread before sending it.
I then tested each branch with 3 players on a benchmark that created and updated a massive amount of objects.
Packet Spread averaged about 40-70ms per game update.
Packet Blob averaged about 8-16ms per game update
Packet Spread Threaded averaged 20-40ms per game update.
I believe that there is a lot of overhead when sending data over a Spring Websocket so it ends up being more efficient to send large single packets instead of multiple small ones.