Best strategy for a multiplayer realtime server?

August 25, 2016 175 views
High Availability Java


I've a problem and I need your help. I'm developing a multiplayer realtime game and I need the advice of any expert in server realtime programming. I'm an expert in client programming and even though I've done the basic server I need in Java, I don't know how to face problems like supporting a big demand of users.

Some characteristics about the needs of my project:

  • The behaviour of the server is similar to a chat system.
  • There won't be any access to hard drive to save/read anything.
  • The amount of heap memory foreach thread managing a room up to 10 players is almost non-existent.
  • In each room thread there is no compute intensive calculations because its behaviour is basically to broadcast message between players.
  • Each thread is going to broadcast every 100 millisecons packets around 5 Kbytes of information.
  • The server is done in Java.


2 Answers

HI Steban,

Unfortunately, there is no simple answer to your question. Assuming you already have the server implemented, the next thing you should do is evaluate how much actual traffic it would be able to sustain. I'd recommend setting up a midrange droplet (like the 2GB of memory and 2 processors we have), getting the server running there and starting to run usage tests.

One of the best ways to verify how your server is behaving is using the top tool (you can read more about it here - ), watch for the java process that your server will be running. Get some people to play the game (you will want to control how many people are actually there playing in this phase) and check how that affects server load. If the machine is seeing too much work (the load average by top is too high) you need a bigger machine, otherwise this one is fine.

And keep doing this until you've reached the amount of people live you think you need. This is what most people will do, as you can see from the Titanfall 2 open beta that's happening this weekend, even the big companies have to perform load tests in their environments.

Thanks a lot for your advice, Mauricio.

My project is about a collection of escape rooms where the users will be able to play online with their friends. The project is a Facebook app, so the client works with WebSockets in WebGL and it's done in Unity.

Another thing I will have to face soon is how to deploy the war file here. I've tested the server as a single thread run through the shell and I've also tested the war file through NetBeans service, but I've yet to test it on a hosting service.

Have another answer? Share your knowledge.