I have set up a server for a little game. The clients send their movement data in a certain interval to the server. The server sends data about the other players, also in a certain interval, to the clients. If I add more players, the performance gets worse. How can I improve the performance now?
Does sending single attributes instead of objects increase the speed?
Can I create a more stable performance by using a bigger interval?
Or do you have other ideas?
And is there a debugging tool to check which server actions slow the server down?
Best How To :
You can actually improve performance in three ways :
1 - Reduce the size of instructions you send on the socket.
You can achieve this by :
- Minimify your JSON
- Use MessagePack which is smaller than JSON
2 - Send just what you need.
- If you need to move the player, you just need to send the position.
- If you need to pop a new player, then send the complete object and store it client-side.
3 - Reduce the frequency.
You don't need to send every positions. You can, for example, send a player position every second. On the client, you will then need to add an animation which moves the player to the position with an animation that lasts one second. Here's an article that well explains game networking techniques