Skip to main content
Game Backend & Concurrency
2026-03-158 min readBehzad Shirani

Scaling Real-Time Mobile Game Backends to 50k Concurrent Users with ASP.NET Core & Redis

Scaling Real-Time Mobile Game Backends to 50k Concurrent Users with ASP.NET Core & Redis

The Challenge of Mobile Game Launch Spikes

When a mobile game is featured in app stores, traffic does not ramp up linearly — it spikes by 50x in minutes. Every user connection requires token authentication, inventory synchronization, live matchmaking pooling, and state persistence.

If every incoming payload hits a relational database directly, connection pools exhaust within seconds.

```csharp // Example: Thread-safe high-throughput session state caching in Redis public async Task<PlayerSessionState> GetOrRefreshSessionAsync(string playerId, CancellationToken ct) { var cacheKey = $"player:session:{playerId}"; var cached = await _redisDatabase.StringGetAsync(cacheKey); if (cached.HasValue) { // Extend sliding expiration await _redisDatabase.KeyExpireAsync(cacheKey, TimeSpan.FromMinutes(30)); return JsonSerializer.Deserialize<PlayerSessionState>(cached); } // Fallback to cold database storage var state = await _repository.LoadPlayerStateAsync(playerId, ct); await _redisDatabase.StringSetAsync(cacheKey, JsonSerializer.Serialize(state), TimeSpan.FromMinutes(30)); return state; } ```

Architecture Pillars

1. **Separation of Read State vs. Write State:** Read-heavy match stats are stored purely in memory in Redis cluster shards. 2. **WebSocket Keep-Alives & Heartbeat Aggregation:** Preventing TCP socket exhaustion by batching client pings every 5 seconds. 3. **Optimistic Locking for Currency and Inventory:** Atomic Redis scripts (`EVAL`) for currency deduction prevent race conditions without table locks.

Key Takeaway By designing the game server around stateless ASP.NET Core web nodes and clustered Redis state engines, our fleet handles over 50,000 active concurrent matches with sub-20ms latencies.

#ASP.NET Core#Redis#WebSockets#Game Dev#High Concurrency
Behzad Shirani — Senior Software Developer & SysAdmin