Link to original video by Tech Dummies Narendra L

Online games System design backend

High-level system design for massive multiplayer online gaming

  • Clients connect to the pack server to update their applications

  • Clients connect to the login server to check credentials

  • Players connect to the word server, which tracks player entries

  • Game server creates a new instance of the game

  • Load balancer ensures low latency between players

  • Proxy/connection server handles connections, offloading processing overhead from the game server

  • Separate world server coordinates game sessions across multiple game servers

"The key to load balancing is always to keep the latency between two players to a minimum."

Processing overhead and the use of proxy/connection server

  • Processing and operations like TCP or UDP incur CPU and memory overhead

  • Overhead increases as more players join the system

  • The overhead impacts performance when processing packets, decoding, decryption, and decompression are combined with game operations

  • Proxy/connection servers handle the connection overhead, allowing the game server to focus on game logic

"Proxy/connection servers handle the connections, taking care of the overhead, while the game server performs game logic."

Use of world server and game servers for scalability

  • For strategy games like chess, a single server can accommodate multiple game sessions

  • However, for games like Call of Duty or Counter-Strike with extensive data processing and state maintenance, vertical scaling is not sufficient

  • Horizontal scaling is achieved by breaking the game map into multiple pieces, each loaded onto a separate game server

  • World server coordinates multiple game servers for session coordination

"We break the map into different pieces and load them onto individual game servers for horizontal scaling."

Voiceover Maintains and Game Server Hierarchy

  • The voiceover states that the game server hierarchy is maintained by the system.

  • Game server 1 hands over games to game server 3.

  • The responsibility of taking care of different pieces of the map and the game session lies with the system.

  • The role of the world server is to assign a particular layer to a game session and match players to the same game session based on proximity.

  • The world server instantiates a game session once multiple players join.

  • The console server handles connections, authorization, creation, termination, and overall coordination of the game session.

"The responsibility of taking care of different pieces of the map and the game session lies with the system."

Game Plans and Connection Flow

  • The video explains that the system consists of different game plans.

  • When a client joins the connection server, their request is forwarded to the world server.

  • The world server assigns a game session and matches players based on region.

  • Once multiple players join a game session, the world server instantiates the session.

  • Connection handling, including authorization and termination, is managed by the console server.

"When a client joins the connection server, their request is forwarded to the world server for assignment of a game session."

World Server and Game Server Information

  • Clients receive two pieces of information: world server and game server information.

  • The world server provides player information, such as location, and the game server information is needed for displaying objects in the game.

  • The world server gives crucial player information to the client, while the game server handles the actual game rendering.

  • The world server also manages the scaling of game servers when needed.

"The world server provides crucial player information, while the game server handles actual game rendering."

Area Servers and Map Segments

  • Area servers are responsible for managing different segments of the map and controlling game aspects within that region.

  • The map is divided into segments, each managed by a different area server.

  • Concentration of players in certain areas may cause an imbalance in server load, so map segments can be redistributed among the area servers to balance the load.

  • The area servers work in coordination with the game servers to handle player movements and actions.

"Area servers are responsible for managing different segments of the map and controlling game aspects within that region."

Player Awareness of Map Segments

  • Players may not be aware that the map is divided into multiple segments managed by different servers.

  • Players who cross between map segments need to contact the appropriate game server for the map information in the new segment they enter.

  • The world server informs the player of their position and directs them to the respective game server for the requested map information.

  • The system handles this seamlessly with connections established between the player, world server, and game server.

"Players may not be aware that the map is divided into multiple segments managed by different servers."

Implementing seamless transition between map segments

  • Goal is to provide a better user experience for players.

  • Players should not experience lag or glitches when moving between different segments of the map.

  • Strategy is to broadcast the position and state of objects to the adjacent servers to ensure a seamless transition.

  • Rather than sending all the data, only the state of the objects in the border is sent to the adjacent servers.

"To make this seamless transition between different segments of the maps, we have to broadcast the position and state of all the objects in the border to the adjacent servers. This way, the server already knows the state of each object, allowing for seamless transitions."

Importance of game patching and server updates

  • Patching and sending updates to the game is crucial, especially for massive multiplayer online games.

  • Players should be running the same version of the game to ensure fairness and prevent bugs or exploits.

  • Patching also helps address issues like hacking attempts or game vulnerabilities in real-time.

"Every player should be running the same version of the game to maintain fairness. Patching and server updates play a crucial role in addressing game vulnerabilities or hacking attempts."

Handling game server threading and message passing

  • Instead of running separate threads for each connection, a more efficient strategy is to use message passing servers.

  • These servers can handle small messages, such as player information, asynchronously.

  • Examples of message passing servers include Nginx and Node.js.

  • Hybrid approaches that combine multiple thread pools for handling connections, along with message passing, can also be used.

"Instead of having separate threads for each connection, using message passing servers like Nginx or Node.js allows for more efficient handling of small messages between clients and servers."

Strategies for backing up game state

  • Backing up the entire game session is not practical, so individual objects and player states are serialized.

  • Important components for game reestablishment should be prioritized for serialization.

  • Backups are necessary to mitigate the risk of server failures.

"Instead of backing up the entire game session, individual objects and player states are serialized for easier reestablishment. Backups are crucial to handle server failures."

Saving and Persisting Objects

  • To ensure important game data is not lost, objects need to be serialized and persisted.

  • Serialize objects that are affected by players and save them to a storage location.

  • This allows the game session to be repopulated from the saved state if the server fails or something happens to the game system.

"Serialize those objects and save them in some place so that if the server fails or if something happens to the game system, we can just repopulate the whole session of that particular state from the persistent output in storage."

Serialization of Changed Objects

  • In games with millions of objects, it is not efficient to serialize all objects.

  • If an object is changed by interaction with players or other objects, mark it as changed and serialize it.

  • If an object is not changed, it can be populated by the initial state of the game.

"If we know that this particular object was changed by interaction with some other players or some other objects, only then we can have a flag to check if it changed. If it changed, we can serialize and save it. If not changed, we can always populate it by the initial state of the game."

Caching Individual Objects

  • Since combining multiple objects into one serialized output is not feasible, individual objects should be serialized.

  • Cache each object separately to optimize performance.

"Always serialize individual objects. You can't just combine multiple objects into one serialized output and then save it. So, what you always need to do is serialize it individually."

Synchronous Saving

  • Having a system that saves synchronously is not feasible or efficient.

  • Instead, push all the objects that need to be serialized into a queue.

  • Workers on the other end consume the queue and serialize the objects into a database or cache.

"You can't always have a system large enough or powerful enough to save each and every million objects. Instead, you push all the objects which we need to serialize into a queue, and you have a couple of workers on the other end which consumes this and then keep on serializing into DB or cache."

Database Selection

  • The choice of database (SQL or NoSQL) depends on the game size and user base.

  • For smaller games and lower user bases, MySQL can be used.

  • For larger user bases, it is recommended to use a NoSQL-like database.

"If your game size is very less and your user base is very less, you can always go for MySQL. And if your user base is really crossing more than a couple of millions, then it's always suggested to go for a NoSQL-like database."

Content Delivery Network (CDN) for Game Assets

  • In MMO games, loading game assets such as gameplay videos or introduction videos quickly is important.

  • Using a high-performance CDN can ensure assets are loaded in milliseconds.

  • CDN also helps distribute the game to reduce load on servers and facilitates efficient updates during patching.

"CDN plays a very important role in MMO games because there are a lot of gameplay videos or introduction videos. These things should be loaded in the matter of milliseconds. It's always better to use a high-performance CDN to get these sprites or images and videos."

Logging and Analysis

  • Logging is crucial for system analysis in any system, including games.

  • Use a logging system like Elasticsearch with log stash and Kibana for visualization.

  • For game analytics, utilize the Hadoop ecosystem, tools like Spark or Flink, and HDFS for data storage and exploration.

"Logging in any of the systems plays a very important role. Use Elasticsearch plus logstash because Kibana, you can use it directly to explore your logs. Also, game analytics is important. You can straight away use the Hadoop ecosystem and use any of the tools like Spark, Flink, and HDFS to store and explore the data."

"Logging in any of the systems plays a very important role."

Summary from youtubesummarized.com