Introduction
This talk focuses on spacetime DB and is titled "Database-Oriented Design or Why We Built Our MMO RPG Inside a Database." Before delving into the main topic, the speaker provides some background information about Clockwork Labs, a 40-person game studio developing an MMO RPG called BitCraft Online.
BitCraft Online
-
Features: BitCraft Online is a fully persistent, single-world MMO where players can edit the terrain, build buildings, cut down trees, and form societies.
-
Visuals: The speaker shows pictures of the game, including player-built settlements, edited terrain, and various biomes. The art team has done an excellent job creating a beautiful and immersive world.
-
Community: The game has an active Discord community, and players have even created art based on the game's map.
Why Build Inside a Database?
At first, building an MMO RPG inside a database may seem unhinged. However, the speaker believes it might be the only sane way to do it, especially for a fully persistent and editable world like BitCraft. The talk aims to convince the audience that this approach is not only possible but also reasonable.
Technical Requirements
To build a game like BitCraft, several technical requirements must be met:
-
Single Physical World: All players must be in the same physical world, as they can edit the terrain and build buildings.
-
Concurrent Players: The game needs to support a large number of concurrent players, potentially up to 100,000.
-
Server-Authoritative Logic: Server-authoritative logic is required to ensure fairness and consistency.
-
Complex Permissions: Players should be able to set permissions for their friends and other players.
-
Editable Character and World State: All character and world state must be editable and durable.
-
Transactional Transactions: Some transactions, such as trades, must be transactional to prevent item duplication.
-
Real-Time Interaction: Character and world interaction must be real-time, including health and stamina updates.
-
Thousands of Mobs: The game needs to have thousands of mobs for players to interact with.
-
Proximity Chat: Proximity chat is essential for a realistic MMO experience.
-
Tractable Development: The game must be tractable to build for a team of about 10 developers.
Traditional Architecture
The speaker then presents the traditional architecture for building an MMO RPG. This architecture typically includes a game server, a game client, a web server, a database, and a deployment mechanism. The game server has ephemeral and persistent state, and the persistent state needs to be synchronized with the database and sent to the clients.
Challenges with Traditional Architecture
The traditional architecture has several challenges, including:
-
Server-Database Synchronization: Keeping the game server and database in sync is a complex and error-prone task.
-
Client-Server State Synchronization: Setting up client-server state synchronization from the start is difficult and inflexible.
-
Deployment Complexity: Deploying the game server, database, and other components can be a complex and time-consuming process.
The SpaceTime DB Approach
To address these challenges, the speaker proposes using spacetime DB. Spacetime DB is a real-time database that can run procedural code like a game server. By merging the server and the database, the speaker believes that many of the challenges of the traditional architecture can be eliminated.
How It Works
-
Server-Database Merge: The game server and database are merged into a single entity, which can run procedural code and handle transactions.
-
Query-Based Client Synchronization: Clients connect directly to the database and query it for the data they need. The database sends down updates in real time, handling the transport layer, serialization format, type safety, and code generation.
-
Single Binary Deployment: The database is a single binary that can be deployed easily. It handles replication, fault tolerance, and proxying automatically.
Benefits
The SpaceTime DB approach offers several benefits, including:
-
Simplified Architecture: The architecture is simpler and more straightforward, with fewer components and less complexity.
-
Faster Development: Development is faster and more efficient, as developers can focus on the game logic rather than the infrastructure.
-
Improved Performance: The database is optimized for performance, providing faster query execution and better scalability.
-
Enhanced Flexibility: The approach is more flexible, allowing for easier customization and extension.
-
Reduced Costs: The simplified architecture and improved performance can lead to reduced costs, both in terms of development and operation.
Demo
The speaker then presents a demo of spacetime DB in action. The demo shows how to create a simple game inside the database, including adding circles, simulating physics, and updating the game logic in real time without disconnecting the clients.
How It Works Under the Hood
The speaker then explains how spacetime DB works under the hood. The database has an HTTP server, a web assembly instance, an in-memory data store, a query engine, a commit log, and a snapshot tree. The web assembly instance runs the game logic, and the query engine handles SQL queries. The commit log stores the full history of all transactions, and the snapshot tree is used to quickly restore the database state.
Future Work
The speaker then discusses some future work that is planned for spacetime DB, including more aggressive multi-version concurrency control, rewind and replay support, and automatic client-side prediction.
Parting Thoughts
In conclusion, the speaker believes that database-oriented design is the future of game development. By thinking about data as structured data and using techniques to manipulate it, developers can build more efficient, flexible, and scalable games. The speaker encourages the audience to open their minds and think about databases in a new way.
Questions and Answers
The speaker then answers questions from the audience, including questions about data analytics, scale, physics simulation, client-side prediction, support and operations, security, and multi-region latency.
Conclusion
The talk concludes with the speaker thanking the audience for their time and attention. The speaker also invites the audience to sign up for the spacetime DB website and try it out for themselves.