Realtime multiplayer game server architecture

Started by
5 comments, last by hplus0603 3 years, 8 months ago

Hello, I'm planning to build a big browser multiplayer game with gameplay very similar to agar.io but rpg. Game will be containing rooms as It's done in agar.io. 50-100 players max per room. Realtime. 10ms update loop. The server should be scalable, I guess the kafka or some other message broker should be used, but I can't figure out how to design such system to handle 2000-10000 players per day at least or more.

Where player's state should be calculated?If I create websocket server and create single loop It cannot handle such huge bunch of players. How to split player sessions to kafka consumers or to do something to Improve performance in scalable calculation model?

Im using java11+netty+spring for now.

Any thoughts regarding the server architecture will be appreciated!

Advertisement

This is not on-topic for the Game Design forum. Accordingly, this thread has been moved to Networking and Multiplayer.

-- Tom Sloper -- sloperama.com

[quote]The server should be scalable, I guess the kafka or some other message broker should be used,[/quote]

I love Kafka dearly for bulk data ingest, but that probably isn't the right technology choice for a real-time game.

Real-time games use direct communication with the game server, which keeps all the game state in RAM. If you want to play in a browser, you will likely use Websockets for the communication; native games will use either raw TCP streams or, more likely for realtime, UDP messaging, using some custom protocol.

So, very briefly, for your goals:
1. pick a server technology that has the performance and connectivity characteristics you're interested in – node.js/ws, C++/websocketpp, Erlang/cowboy … whatever works for you!
2. build a server process that can receive, process, update, and mirror out gameplay events for 50-100 users. this server might in turn use a REST application server for its persistence needs, or it might talk straight to a database
3. build a simple instance manager that can spin up more server process instances when more people are online, and matchmake people to existing instances as appropriate

The game server will typically receive some ticket/token from a connecting player, use this ticket/token to look up actual player stats, and then instantiate the player in the game world. Whenever significant events happen (death, leveling up, trade, etc) this server will checkpoint the state of the player to persistent storage, but it's generally not possible to keep checkpointing every player every tick. Occasionally checkpointing, say, every 5 minutes, is fairly common, though.

Good luck with your game!

enum Bool { True, False, FileNotFound };

So is It good way to create a room as separated server's thread?
If yes how would you handle players in private room?Private rooms are good option but Im not sure that is a good thing when any player has ability to create new room as thread

@hplus0603 Any your ideas how to handle 1000-2000 players per server tick?

1000 players isn't by itself hard, assuming the simulation load per player is low, and somewhat depending on the size of a tick. If you're sweeping a sphere across a static geometry with precomputed collision, that should be super easy.

Of course, using optimized libraries and high-performance runtimes will matter. Doing a linear scan over objects in PHP will be less efficient than using C++ with a high-quality library like PhysX or ODE or Bullet.

enum Bool { True, False, FileNotFound };

This topic is closed to new replies.

Advertisement