SignalR Scalability: Scaling Real-Time SignalR Applications on Heroku
Scaling a SignalR chat app across multiple Heroku dynos takes two pieces: a Redis backplane so every instance relays hub messages to its own connected clients, and sticky sessions so long-lived WebSocket connections stay pinned to one dyno. The walkthrough builds Microsoft's sample chat on .NET 9, adds Microsoft.AspNetCore.SignalR.StackExchangeRedis with REDIS_URL parsing and TLS settings for Heroku Key-Value Store, and confirms backplane traffic by subscribing to the hub's Redis pub/sub channels. It then deploys with a Procfile and moves to standard-1x dynos, since Eco and Basic dynos cannot scale out. Scaling to three dynos produces 404 and WebSocket errors that sticky sessions are meant to fix.
Related posts
- The Adventures of Rendezvous in Heroku’s New Architecture
Heroku Engineering mediumAdeptMoving Heroku's Rendezvous proxy, which splices CLI and one-off dyno connections across NATs, from EC2 Classic to VPC behind AWS Network Load Balancers with TLS termination broke one customer's request-scoped one-off dyno workflow with H12 router timeouts. The root cause was a single-threaded agent loop using IO.select on the raw TCP socket. The NLB's larger TLS frames left decrypted bytes buffered inside OpenSSL's SSLSocket where IO.select couldn't see them, so the loop blocked until an idle timeout longer than the router's 30s limit. The fix split the agent into one thread per direction and changed the read logic so buffered SSL data is drained before selecting again.
- Migrating Millions of Concurrent Websockets to Envoy
Slack Engineering mediumAdeptSlack moved its websocket ingress tier, serving millions of concurrent connections, from HAProxy to Envoy Proxy. HAProxy reloads spawned long-lived draining processes that had to be reaped and rate-limited. Envoy's dynamic clusters, hot restarts and panic routing removed that operational overhead. Envoy config was generated through custom Chef resources with --mode validate checks, and traffic shifted region by region via NS1 weighted DNS in 10–100% steps on a parallel stack, completing in six months with no customer impact. Key lessons: the organically grown HAProxy config hid behaviours services depended on, a test suite for load balancer routing would have saved effort, and limiting Chef libraries to a subset of Envoy features kept them simple but made later additions like vhosts awkward.
- Rapidly scaling online storage to serve over 1 billion ChatGPT users
OpenAI mediumAdept
Habitat, OpenAI's online storage platform, grew from a client-side Python library over Azure Cosmos DB into a centralized Python service handling 70M+ requests per second and 500+ PB across about 40 regions. It moved to a service because coordinating client-library rollouts across dozens of services had become slow and error-prone. Running Python at this scale meant fighting tail latency from asyncio event-loop scheduling delay, which the team measured directly and controlled by keeping per-process concurrency low and scaling out worker processes. Specific fixes included shrinking and jittering Statsig feature-flag config refreshes, and switching aiohttp's LIFO connection reuse to FIFO to break a metastable failure that concentrated load on already-slow processes.
- Real-time Messaging
Slack Engineering mediumAdeptSlack's real-time messaging runs on four Java services: stateful in-memory Channel Servers sharded by consistent hashing, regionally deployed Gateway Servers holding websocket subscriptions, stateless Admin Servers bridging the Webapp backend, and Presence Servers tracking online users. Consistent hash ring managers (CHARMs) registered in Consul replace failed Channel Servers in under 20 seconds. Messages flow from Webapp to Admin Server to the owning Channel Server, which fans out to every subscribed Gateway Server worldwide. Transient events like typing indicators skip persistence and enter directly through the Gateway. The system delivers messages globally within 500ms and handles tens of millions of channels per host.
- Router 2.0 Common Runtime Router: The Road to Beta
Heroku Engineering mediumAdeptHeroku is replacing Hermes, its decade-old Erlang Common Runtime router, with Router 2.0 written in Go. Hermes became hard to upgrade: Erlang expertise declined, its dependencies were pinned, and features like HTTP/2 were blocked. The new L7 router runs in-memory behind an existing L4 proxy that also terminates TLS. Using the Strangler pattern, it routes per-app traffic either through Hermes or directly to dynos, and it shares an HTTP library with the Private Spaces router. Before beta, the team added gated deployment automation, continuous load testing tied to SLOs, and W3C Network Error Logging to measure real client routing failures.