惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

小众软件
小众软件
B
Blog RSS Feed
美团技术团队
博客园 - 【当耐特】
C
Check Point Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
M
MIT News - Artificial intelligence
aimingoo的专栏
aimingoo的专栏
J
Java Code Geeks
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Microsoft Azure Blog
Microsoft Azure Blog
博客园 - 司徒正美
T
Tailwind CSS Blog
Last Week in AI
Last Week in AI
Google DeepMind News
Google DeepMind News
D
DataBreaches.Net
人人都是产品经理
人人都是产品经理
N
Netflix TechBlog - Medium
Vercel News
Vercel News
P
Proofpoint News Feed
IT之家
IT之家
I
InfoQ
腾讯CDC
H
Hackread – Cybersecurity News, Data Breaches, AI and More

Stonecharioteer on Tech

I Traced My Traffic Through a Home Tailscale Exit Node What Was I Reading Last? In Three Not-So-Easy Pieces Dogfooding Is Hard Code blocks in your books, finally GoForGo v0.9.0 Merrilin - We built an app to read books I use a Macbook now Data Structures & Algorithms - Preparing for Interviews Using a local DNS namespace for local service discovery Direction KOllector - Publishing KOReader Highlights gbt: branches touched in the last 24 hours A Soiree into Symbols in Ruby Some Smalltalk about Ruby Loops Ruby Blocks Returning from Ruby Blocks, Procs and Lambdas My Linux Laptop Finally Works: How Claude Helped Me Fix Years of Annoyances TIL: Watchexec - Modern File Watching for Development Workflows A Less Busy Mind GoForGo - Learn Go through live examples Migrating My Old Blog to Hugo with Claude The Qtile Window Manager: A Python-Powered Tiling Experience Read the RFCs that Built the Internet Py-x-Protobuf - Or How I Learned to Stop Worrying and Love Protocol Buffers Python Reverse a List New Beginnings Leaving ChainSafe Systems Screen Lock for Cinnamon Desktop using Zenity and Terminal Commands Crews Not Teams A System for Getting Better at LeetCode
TIL: How Discord Handles 2.5 Million Concurrent Voice Users
2021-04-21 · via Stonecharioteer on Tech

Discord’s WebRTC Architecture at Scale

How Discord Handles Two and Half Million Concurrent Voice Users using WebRTC

Fascinating deep dive into one of the largest WebRTC deployments in the world:

The Scale Challenge:

  • 2.5 Million concurrent voice users
  • Multiple Platforms: Desktop, mobile, web browsers
  • Global Distribution: Servers worldwide for low latency
  • Real-time Requirements: Sub-100ms latency for good UX

Technical Architecture:

Client-Side Innovations:

  • Custom WebRTC Stack: Modified libwebrtc for Discord’s needs
  • Adaptive Bitrate: Dynamic quality adjustment based on network
  • Noise Suppression: AI-powered background noise removal
  • Echo Cancellation: Advanced acoustic echo cancellation

Server Infrastructure:

  • Voice Servers: Geographically distributed for low latency
  • Load Balancing: Smart routing to optimal voice servers
  • Redundancy: Multiple servers per region for reliability
  • Auto-scaling: Dynamic capacity based on demand

Key Technical Challenges:

Network Traversal:

  • NAT Traversal: Complex networking behind firewalls/routers
  • STUN/TURN Servers: Helping clients find connection paths
  • UDP vs TCP: Balancing reliability with latency

Audio Processing:

  • Codec Selection: Opus codec for efficiency and quality
  • Jitter Buffering: Smoothing out network irregularities
  • Packet Loss Recovery: Maintaining quality during network issues

Mobile Optimizations:

  • Battery Efficiency: Minimizing power consumption
  • Network Switching: Seamless handoff between WiFi/cellular
  • Background Processing: Continuing calls when app backgrounded

Performance Optimizations:

Latency Reduction:

  • Geographical Proximity: Voice servers close to users
  • Direct P2P: Peer-to-peer when possible, server relay when needed
  • Protocol Tuning: Custom UDP protocols for voice data

Quality Improvements:

  • Dynamic Quality: Adjusting bitrate based on network conditions
  • Error Correction: Forward error correction for packet loss
  • Audio Enhancement: Real-time audio processing improvements

Lessons for Developers:

  • WebRTC Complexity: Real-time communication is incredibly complex
  • Infrastructure Matters: Geographic distribution is crucial for latency
  • Mobile Considerations: Battery and network constraints are significant
  • Monitoring: Extensive telemetry needed for debugging at scale

This case study demonstrates the immense complexity behind seemingly simple voice chat functionality and the engineering excellence required to make it work at Discord’s scale.