Scale Out

We are at the 7th stop from roadmap. I’ll talk about how to scale out your online games.
The core part of scale out is to keep a manageable number of users per server as well as assign users to geographically nearby servers.

If one server is cramped with too many users while another is vacant, you are wasting computing resources. The cramped server will be slow to response to user requests, thus users will experience big latency.
If users in one region need to talk to servers from another region, they will experience big latency even if the server is vacant. For example, a user in Beijing will have around 20KB/s speed with occasionally packet loss when trying to connect to a server in New York.

To solve the problem of overcrowding server, you need a load balancer. If you want to go the easy way, just randomly assign users to available servers. In practice this will give pretty good result.
If you want to do it the smart way, you need to think the design carefully. The problem is that how does the balancer know the load of each server? If you try to check the server, it’s also communication overhead.

World_Gate solution is like this.

The Gateway serves as a guard and balancer. The Hub is the real server that users will use.
Users first connects to Gateway to start a request to join. The Gateway will keep an estimated load of each hub. It checks the condition and returns a proper hub. Then increase the estimated load of that hub.
Next users connect to the target hub returned by Gateway. Hub will talk to Gateway to check whether this user has the right to consume its resources. Besides, hub will also send its current load to Gateway for update.
In this design, there’s no overhead, just some extra bytes in addition to the original message. This design can also handle network failure.

To solve the problem of geographic distance, you need to deploy your servers around the globe. That’s the only way to solve it.
Your cloud service providers will usually have many option as to location. They will also offer homogeneous servers. So you just pick a location and deploy your server using the same method.

There’s also the problem of synchronization among servers. This is actually a big problem for distributed system.
Luckily, for multi-player games, this usually is not a problem, since each server is separated. Users play in one server and all their data are just stored in that server.They can start a new game in another server, but not inherit their saves. That’s the normal construct.