Best strategy for a multiplayer realtime server?


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.


Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

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.

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.