Skip to content

In development. Expect rough edges and changes. The source code is not public yet.

Slack Engineering 6 min read Case study mediumAdept

Real-time Messaging

Slack'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.

Assumes: consistent hashingWebSocketspub/sub fan-out

Related posts

  • Slack Overflow: How We Scaled Slack to Support 1000s of Developers

    Railway mediumAdept

    Railway built a two-way bridge between Slack Connect channels and its in-house Help Station support tool, auto-creating channels when customers hit growth thresholds. Early assumptions failed: external Slack Connect users can't invoke the host's slash commands, a "!support" workaround went unused, and Socket Mode silently stopped delivering messages after deploys. The fix was to thread every message by default, classify intent as sales or support with GPT-4o-mini, let employees impersonate so replies come from real people, switch Bolt to HTTP routes, and run message processing through Temporal workflows with idempotent activities so crashes don't lose messages. Railway credits Slack with 50x better engagement and 8x faster response times than email, and is opening Slack Connect to all Pro teams.

  • How OpenAI delivers low-latency voice AI at scale

    OpenAI hardMaster

    OpenAI rearchitected its WebRTC stack for ChatGPT voice and the Realtime API by splitting a stateless UDP relay from a stateful Go/Pion transceiver that owns ICE, DTLS and SRTP state. The design avoids one-public-port-per-session media termination, which fits poorly with Kubernetes and cloud load balancers. Server-generated ICE ufrags encode routing hints, so the relay can steer the first STUN packet to the owning transceiver without an external lookup. Relay flows are kept in memory with Redis as a backup, and Cloudflare geo-steered signaling plus a globally distributed relay fleet shorten the first hop and cut setup latency.

  • Using Server Sent Events to Simplify Real-time Streaming at Scale

    Shopify Engineering mediumAdept

    Shopify replaced its 2021 BFCM Live Map delivery path, in which WebSocket fed a presentation layer that clients polled through a mailbox system every 10+ seconds, with a Go Server Sent Events server. The server subscribes to Kafka topics produced by a Flink pipeline and pushes data straight to registered clients. SSE fit because the visualization only needs one-way, read-only push over plain HTTP with built-in reconnection; the server scales horizontally behind NGINX load balancers, and per-pod connection limits were sized with a Java load tester built on okhttp-eventsource. During BFCM 2022 the system had 100% uptime, SSE delivered data within milliseconds of availability, and end-to-end latency from event creation to display was about 21 seconds.

  • Lessons learnt from building reactive microservices for Canva Live - Canva Engineering Blog

    Canva Engineering mediumAdept

    Canva Live delivers near real-time audience questions to presenters through a hybrid design: presenters receive updates over WebSockets, while audience members use plain request/response APIs, all behind a gateway that multiplexes client sockets onto single connections per RPC node and uses service discovery instead of an ALB. Redis on ElastiCache in cluster mode is the datastore, accessed via the lettuce reactive Java client. Redis Streams carry per-session question events, polled with XRANGE and later moving to blocking XREAD, and a SortedSet with ZADD/ZCOUNT tracks participants active in the last 10 seconds. Practical lessons include building for scale from day one, pushing filtering into Redis data structures, using hash tags so transactional keys share a shard (Redis transactions don't roll back), and reserving streaming connections for chatty interactions.

  • Migrating Millions of Concurrent Websockets to Envoy

    Slack Engineering mediumAdept

    Slack 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.

The quest for software engineering knowledge.

Look:
Layout: