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

推荐订阅源

IT之家
IT之家
博客园 - 聂微东
雷峰网
雷峰网
Microsoft Azure Blog
Microsoft Azure Blog
WordPress大学
WordPress大学
Hugging Face - Blog
Hugging Face - Blog
S
SegmentFault 最新的问题
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
T
Tailwind CSS Blog
博客园 - 三生石上(FineUI控件)
V
Visual Studio Blog
博客园 - 司徒正美
爱范儿
爱范儿
月光博客
月光博客
阮一峰的网络日志
阮一峰的网络日志
博客园_首页
博客园 - 【当耐特】
Jina AI
Jina AI
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
酷 壳 – CoolShell
酷 壳 – CoolShell
大猫的无限游戏
大猫的无限游戏
小众软件
小众软件
人人都是产品经理
人人都是产品经理
V
V2EX

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.