Reputation: 51
I'm developing a multiplayer 2D-game where players and other objects move on the screen in a simple coordinate system. So player's client sends its movements to the server, and according those movements, server's game room thread periodically (maybe 50-100ms) calculates new speed, coordinates and angle for every object. Then it sends data to every player about those changes.
For example, we have ten players which can send their movements three times in a second, server has to send those movements forward to everyone. Considering other player actions than just movement, there could occur tens of little messages in a second, and that's just in one room.
So here's a bunch of questions:
1) Is Netty the framework I'm looking for? It's a real-time game, so every millisecond counts. Low latency is the most important requirement. If player's ping goes over 30, the playing is pretty poor and laggy.
2) If so, I would also like to hear your every advice for optimization and settings for this kind of server, which sends small packets, but there's a lot of them. I'm estimating that the peak of concurrent players will be about 2000-3000 users playing in 100-200 rooms, so I would be really happy if the server can handle that amount of players playing the game without lag.
3) Every game room has some kind of own thread which loops and runs the game. Is there a proper way to do this kind of threads, so it doesn't effect much to the server's normal functionality?
Thanks for your answers!
Upvotes: 1
Views: 5997
Reputation: 141
Take a look at this netty game server from github. You can get some good pointers and patterns here. Maybe you can use it directly also for your purposes
Upvotes: 3
Reputation: 23557
Netty can do the job. Its very well suited for high-troughput and low latency. So I you should give it a try. I think it should "just work" out of the box for you ;)
Netty comes with a NIO (non-blocking) and OIO (blocking) implementations. If you are going with NIO (which I recommend) then I will recommend to try to design your api to be event based and use as less threads as possible. Otherwise it may be hard to scale if you have thousands for "game rooms".
Upvotes: 1