WebSocket optimization tends to follow a predictable pattern. You build the connection layer, get events flowing, ship the feature, and move on. Compression is an afterthought — something you bolt on later, or maybe delegate to the transport layer and forget about entirely.
Discord's engineering team learned this lesson at a scale most of us will never encounter, and the details of what they did are worth paying attention to even if your user count has fewer zeros.
The Problem With "Good Enough" Compression
When Discord migrated their gateway compression from zlib to zstandard, they cut WebSocket traffic by 40%. That is not a rounding error. That is nearly half your bandwidth costs, half your mobile data consumption, and a meaningful reduction in latency for clients on constrained connections.
Zlib has been the default choice for so long that most developers treat it like gravity — invisible, assumed, and not worth questioning. Zstandard (zstd) offers significantly better compression ratios at comparable or faster speeds, particularly on repetitive structured data like JSON event payloads. For a platform pushing millions of concurrent gateway connections, switching algorithms is not a trivial migration. Discord spent six months on it. That timeline tells you something: compression strategy is real engineering work, not a config flag you flip on a Tuesday afternoon.






