Sitemap
The Backend Playbook

Delve into the world of backend development with in-depth articles, tutorials, and best practices. This publication covers server-side programming, database management, API design, and performance optimization, providing valuable insights for developers looking to build scalable,

How Discord Reduced WebSocket Traffic by half

Lessons in Real-Time Optimization

5 min readNov 25, 2024

--

Press enter or click to view image in full size
discord

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:

--

--

Coding Guy
Coding Guy

Written by Coding Guy⁠

I love to dig up deep into software, I am an IIT Delhi Graduate with 8 years into coding

The Backend Playbook
The Backend Playbook

Published in The Backend Playbook

Delve into the world of backend development with in-depth articles, tutorials, and best practices. This publication covers server-side programming, database management, API design, and performance optimization, providing valuable insights for developers looking to build scalable,