Serverless Game Servers
Launch an authoritative game server for every match instantly. Scale to millions of concurrent players without managing fleets or Kubernetes.
1import { actor } from "rivetkit";23export const deathmatch = actor({4 state: { players: {}, scores: {}, map: 'arena_1' },56 actions: {7 join: (c, { name }) => {8 c.state.players[c.connectionId] = { name, hp: 100, pos: {x:0, y:0} };9 c.broadcast("player_join", c.state.players);10 },1112 move: (c, { x, y }) => {13 // Authoritative movement validation14 if (isValidMove(c.state.map, x, y)) {15 c.state.players[c.connectionId].pos = { x, y };16 c.broadcast("update", { id: c.connectionId, x, y });17 }18 }19 }20});The Game Loop
Traditional serverless functions die after a request. Rivet Actors stay alive, maintaining the game state in memory and ticking the simulation as long as players are connected.
Authoritative Logic
Run your game logic (movement, hit detection, inventory) on the server to prevent cheating. The Actor is the single source of truth.
Instant Connectivity
Clients connect directly to the specific Actor instance hosting their match via WebSockets. No database polling latency.
Persistence on Exit
When the match ends, the final state (scores, loot, XP) is automatically saved to disk.
Built for Multiplayer
Infrastructure primitives that understand the needs of modern games.
Lobby Management
Create persistent lobby actors that hold players before a match starts. Handle chat, loadouts, and ready states.
Matchmaking
Use a singleton 'Matchmaker' actor to queue players and spawn new Match actors when groups are formed.
Turn-Based Games
Perfect for card games or board games. Actors can sleep for days between turns without incurring compute costs.
Leaderboards
High-throughput counters and sorting in memory. Update scores instantly without hammering a database.
Economy & Inventory
Transactional state for trading items or currency. Ensure no item duplication glitches with serialized execution.
Spectator Mode
Allow thousands of users to subscribe to a match actor to watch real-time updates without affecting player latency.
Real-Time Strategy (RTS)
A persistent world 4X strategy game where thousands of players move armies on a shared map.
- Sharding: Map divided into hex grids, each controlled by an Actor
- Fog of War: Calculated on server, only visible units sent to client
- Persistence: Game state survives server updates seamlessly
Integrates with your engine
Launch day ready.
Focus on the gameplay. Let Rivet handle the state, scaling, and persistence.