Member-only story
How Discord Reduced WebSocket Traffic by half
Lessons in Real-Time Optimization
This weekend, I was reading through one of the tech pages in discord trying to checkout how Discord managed to reduce it’s websocket traffic by almost half. In this article, I will help to list down my findings and the smart techniques that they used and the lessons that we as a developer can learn to implement in our regular code base.
The Problem
As Discord’s user base grew, their WebSocket bandwidth usage ballooned, particularly affecting users on mobile devices or slower connections.
The team identified several bottlenecks:
- High Bandwidth Usage: JSON, their data format of choice, added unnecessary overhead to WebSocket messages.
- Redundant Data Transmission: Full snapshots of data were sent, even when only small parts had changed.
- Limited Mobile Performance: Users on restricted networks experienced delays or higher data costs.
Faced with these challenges, Discord’s engineers set out to optimize WebSocket traffic while maintaining a high-quality user experience.
Discord’s Approach
Discord tackled these inefficiencies using a multi-pronged strategy:









