How Discord rebuilt its stack to crush API lag
- Database fleet shrinks: Migrating trillions of messages from Apache Cassandra to ScyllaDB helped Discord cut cluster nodes from 177 down to 72 while boosting speed, according to Bo Ingram on the Discord Engineering Blog and tech creator @kncongnghe on TikTok.
- Rust replaces bottlenecks: Discord moved critical data services and API pathways to Rust while adding request coalescing to eliminate hot partitions, as detailed by ByteByteGo and YouTuber Francesco Ciulla.
- Smarter real-time routing: To stop localized spikes from degrading global API latency, technical breakdowns on Medium, Substack, and Dev.to highlight stateful connection routing, backpressure controls, and compact 2–14 byte binary WebSocket frames.
- Client fixes underway: While a Substack report points to a Rust and GPUI client rewrite called Project Phoenix, TikTok creator @elmershelton651 notes Discord is currently deploying an interim 4GB RAM auto-restart patch for memory leaks.
Swapping Cassandra for ScyllaDB
- Fewer servers, faster reads: According to Discord Senior Staff Software Engineer Bo Ingram and TikTok explainer @kncongnghe, shifting trillions of messages from Apache Cassandra to ScyllaDB let Discord shrink its database footprint from 177 servers to 72.
- Request coalescing kills spikes: ByteByteGo explains that pairing a C++-based datastore with custom Rust data services and request coalescing eliminated the hot partitions that previously stalled message traffic.
- Sub-millisecond super-disks: Systems engineer Selva on Selva's Tech Blog breaks down how combining RAID0 local SSDs with persistent disks—dubbed super-disks—pushed Discord's disk read latency into sub-millisecond territory.
Hardening the real-time gateway
- Tiny binary frames: A Dev.to protocol breakdown highlights how a single-round-trip HTTP-to-WebSocket upgrade replaces heavy HTTP request headers with persistent 2–14 byte binary frames.
- Containing traffic storms: Analyses on Medium and Dev.to note that stateful connection routing, intelligent backpressure controls, missed event queues, and reconnection backoff keep localized bursts and network hiccups from triggering API thundering-herd failures.
- Tracing without full rewrites: Substack deep dives detail how Discord paired high-concurrency gateway fan-out strategies with custom distributed tracing in its Elixir backend to pinpoint cross-service bottlenecks without rewriting core infrastructure.
Expanding Rust beyond servers
- API paths go Rust: YouTuber Francesco Ciulla highlights Discord's move of performance-critical backend services and API pathways from Elixir and Python to Rust, echoing stack-switch explainers from creators The Program One and Oliver Jumpertz.
- Project Phoenix client overhaul: One Substack report covers Discord's Project Phoenix effort, which moves client logic to Rust and GPUI to clear performance bottlenecks and pursue low-memory, near-zero-lag responsiveness.
- Temporary memory leak bandage: In the meantime, TikTok creator @elmershelton651 reports Discord is rolling out a temporary auto-restart feature that triggers past 4GB of RAM usage without interrupting active voice calls.
💬 Notable Signals
“Why did Discord switch its tech?”
“How three changes saved Discord from falling apart”
“Discord is rolling out a temporary fix for its memory leak issue, implementing an auto-restart feature that activates after 4GB of RAM usage.”