Streamline game data management with MongoDB Atlas.
Use cases: Analytics
Industries: Media
Products: MongoDB Atlas, MongoDB Atlas Global Clusters, MongoDB Atlas Search, MongoDB Atlas Charts, MongoDB Aggregation, MongoDB Atlas Data Federation
Partners: Unity Game Engine, Amazon EC2
Solution Overview
In the gaming industry, managing data such as player profiles, inventory, and game states is a challenge. This solution, named Leafsteroids, uses MongoDB Atlas to streamline and improve game data storage. Atlas Clusters hold player profiles, Atlas Charts enable real-time player dashboards, and Atlas Search enables user-friendly search interactions. This solution allows for global scalability, efficient data management, and user-focused design.
Reference Architectures
The following diagram displays what a game data management system looks like without MongoDB:
Figure 1. Reference architecture without Atlas
This approach involves building a global query router, replication services betweeen multiple nodes across the globe, and integrating different storage options. The architecture also requires a separate search engine and visualization tool, with a serverless query service to federate the data into the visualization tool.
In contrast, the following diagram displays game data management architecture with MongoDB:
Figure 2. Reference architecture with Atlas
With MongoDB Atlas, you can host your data, generate visualizations, and perform search on a single platform by using MongoDB Atlas Global Clusters, Online Archive, Atlas Search, Atlas Charts, and Atlas Data Federation.
Data Model Approach
The following diagram displays the data models used by this solution:
Figure 3. Data model approach illustration
A Recording represents a player's gameplay from an event, including scores, moves, and statistics. Each Recording stores a subset of the Player and Event data types by using the extended reference pattern. This design enhances query performance by allowing selective field embedding. Additionally, it offers flexibility to add and change data in the future.
In massive online games with billions of players like PUBG, data locality is critical for optimal experience and to satisfy legal requirements. To support these needs, the Players and Recordings collections are sharded based on location ISO codes. Atlas Global Clusters associates ISO Country and Subdivision codes to zones of shards in a specific cloud region. This is used to route query and write requests, ensuring the best performance.
Build the Solution
For detailed instructions on how to build this solution, see the GitHub repository.
Features and Integration
This solution provides the following architecture features:
Atlas Global Clusters ensure an uninterrupted gaming journey regardless of a player's geographical location. For data precision, player information is stored based on ISO country codes.
Atlas Online Archive automatically offloads game data that is older than 90 days to optimize storage. This is especially useful for games with millions of players and game runs, as these generate large amounts of data that can increase costs and impact performance. Additionally, this solution uses Atlas Data Federation so you can access both recent and historic data.
User Experience Highlights
The solution offers the following user highlights:
A player dashboard, supported by Atlas Charts, ensures real-time updates on in-game achievements and progress. By using Atlas Charts' filtering and embedding features, you can repurpose dashboards for players and events.
Atlas Search provides features such as autocomplete and fuzzy matching, allowing players to search for their nicknames in the Web UI.
Architecture
This solution's architecture includes the following components:
Game Client: Developed using Unity3D, .NET, and C#
Game Server: Built on ASP.NET Web API, .NET, C#, and the MongoDB .NET/C# Driver
Website: Crafted as a Blazor Server Application using .NET and C#
Steps
The README in the GitHub repository contains a more detailed version
of the following procedure.
Key Learnings
Global clusters promote scaling: Use global clusters, read from secondary, and write to primary to scale horizontally and cater to a global audience without side effects and latency.
MongoDB's document model promotes flexibility and performance: Leverage the document model to store all data for a single game run in a single document, but serialize a subset during run time to boost performance.
Shard data based on player location: By storing data based on ISO codes, Atlas Global Clusters enable increased performance and easier scalability, allowing shard and zone additions without service disruptions.
Author
Sigfrido Narvaez, MongoDB
Dominic Frei, MongoDB
Hubert Nguyen, MongoDB