Search code examples
c++serverscalabilitymultiplayerenet

Scalable login/lobby servers for a multiplayer game


I am developing a multiplayer game (client-server model) and I am stuck when it comes to scaling its servers.

I understand that most games never even reach 10 000+ players, and I don't think mine will either. Though if I would be very lucky to get that I want to develop the servers so they cannot become a huge obsticle later.

I have searched a lot for a solution to my problem on the internet, checking GDC talks about it and checking other posts on this website, but none of them seems to solve my specific problem.

My current setup is below and all servers are written in C++ using ENet as my network library.

Game server

This server handles the actual gameplay of the game and requires quite a lot of CPU and packages being sent between the server and its connected clients. But this dedicated server is hosted by the players themselves, so I don't have to think about scaling it at all.

Lobby server

This server handles the server list, containing all servers currently up.

  • All game servers are sending a UDP package to this server every 5 seconds to say they are still alive. This is so the lobby server can keep an updated list of all servers currently online.

  • All clients are sending a UDP package to this server when they want to fetch all servers (which is only in the server list screen), and the lobby server sends back a list of all servers. This does not happen that often and the lobby server is limited to send 4 servers per second to a client (and not a huge package containing all servers).

Login server

This server handles creating accounts, lost password, logins, friends and their current game status, private messages to other logged in players and player profiles that specifies what in-game items they have.

  • All clients are sending a UDP package to this server every 5 seconds to say they are still alive, while also sending what game they are currently in. The server then sends back their friend lists online/offline/in-game statuses. This is so their friends can keep an updated list of which friend is online/offline/in-game.

  • It sends messages only with player actions otherwise, like creating an account, logging in, changing/resetting password, adding/removing/ignoring a friend, private messages to friends, etc.

My questions

What I am worried about is that my lobby and login server might not be scalable and that they would have too much traffic on them.

1. Could they in theory be hosted on just a single computer? Or would it be too much traffic for 10 000+ players?

2. If they can be hosted on a single computer, will the servers still not have issues for people that live far away?
Would it be better to have the lobby and login servers per region of the world in that case? The bad thing about that is that the players would not be able to see servers in the US if they live in Europe, and that their account and items would not exist on the other servers.

3. Might be far-fetched, but if I would rewrite both servers to instead be on a website with a database and make the client/game server do web requests instead (such as HTTPS or calling a php with specific headers), would it help in solving my problems somehow?


Solution

  • All your problems and questions are solved by serverless cloud based solution AWS Lambda e.g. or similar. In this case the scalability is not your problem. Just develop the logic. This will save you much time.

    If you would like to make servers as single app hosted by your own server. Consider using something like e.g. Go instead of C++. It's designed exactly for these purposes. I mean highly loaded web/network services.