SlideShare a Scribd company logo
Architecting your WebRTC
application for scalability
Alberto Gonzalez and Arin Sime
TADSummit
Nov 8-9, 2022
@WebRTCventures
Alberto Gonzalez, CTO
Arin Sime, CEO
Agenda
• Why it’s not easy to build scalable apps
with WebRTC
• Open Source vs CPaaS
• So I just need an SFU or MCU to scale
my app?
• RTC orchestration and containers
• Stickiness, persistence and load testing
• Optimizations: App optimizations, media
optimizations (e.g: codecs)
How to Architect your
WebRTC application for
scalability!
WebRTC is not quite this simple…
• STUN/TURN servers
• Application Signaling
• Video codecs
• Browser/Mobile Support
• Recording
• Group chat/scaling
• Broadcasting
@WebRTCventures
4 Ways to build your app…
1. To the standard, ie “build
your own stack”
2. Unbundled WebRTC
3. Open source media servers
4. CPaaS – Communications
Platform as a Service
@WebRTCventures
#1 – Building to the WebRTC Standard
• Compiling webrtc lib
• STUN/TURN servers
• Application Signaling
• Video/audio codecs
• Group chat/scaling
• Browser/Mobile Support
• Recording/Other Add-on features
• Can better utilize capabilities like
WebCodecs, WebTransport and
control low level details for specific
use cases
You must build and handle of the following –
with great power comes great responsibility!
https://webrtc.org
@WebRTCventures
#2 – Unbundling WebRTC
May be appropriate when you find yourself saying “I wish WebRTC would do this instead…”
@WebRTCventures
Typical WebRTC
media
server
Capture Encode Send Receive Decode Play
WebAssembly
media
server
Capture
Web
Codecs
Web
Transport
Web
Transport
Web
Codecs
Play
Diagram adapted from a presentation by Tsahi Levent-Levi on WebRTC Live, bloggeek.me
Unbundled WebRTC - Allows use of other standards to have more control of the codecs, transport, as well as add in insertable streams
#3 – Open Source Media Servers
Media Servers will handle:
• video/audio details
• part or all of the signaling
• Possibly STUN, TURN
• Scaling capabilities
• Could be SFUs or MCUs
• Browser/Mobile support
But you host/manage:
• All infrastructure and updates
Media
Servers
Your cloud servers
@WebRTCventures
#3 – Open Source Media Servers
Media
Servers
Your cloud servers
janus.conf.meetecho.com
jitsi.org
@WebRTCventures
Popular examples:
Pion.ly
mediasoup.org
LiveKit.io
#4 – CPaaS – Communications Platforms
Your
Application
servers
A CPaaS will handle:
• All WebRTC support / updates
• Media Servers
• STUN/TURN
• Web/Mobile Support
• Additional features like Recording, SMS,
Voice/VOIP, Transcription, etc
But you pay according to usage
CPaaS
@WebRTCventures
#4 – CPaaS – Communications Platforms
Your
Application
servers
CPaaS
@WebRTCventures
Popular examples:
It’s all about tradeoffs…
WebRTC
architecture
WebRTC
Standard
Unbundled
WebRTC
Open Source
Media
Servers
CPaaS
Up front cost High High Medium Low
Ongoing cost Low Low Low High
Technical
difficulty
High Medium-High Medium Low
Features
included
Low High* Medium High
@WebRTCventures
*Not really included, but you have flexibility to
build your own on top of the underlying APIs
And what about
intellectual
property?
Also, what
works for you
today does not
have to be your
long term
choice.
WebRTC Scaling Challenges
@WebRTCventures
SFUs or MCUs can help scale WebRTC
MCU – Multipoint Control Unit
• Handles mixing of video/audio streams in a central server
so each participant only has one stream to deal with
SFU – Selective Forwarding Unit
• Each participant only connects to the SFU, but receives
unique streams for each participant
Either can add features beyond scaling
• Recording
• Broadcasting
• Interface to other services like transcription or VoIP legacy
systems
@WebRTCventures
MCU example
• Multipoint Control Unit
• Central server mixes all audio and video
• Participants only gets one downloaded stream
each for audio and video
• MCU controls a composited layout of that video for
everyone, which can be nice but also introduces
latency
• Heavy processing is required on a MCU, but offers
more predictable bandwidth requirements
Media Servers offering MCU capability (not a comprehensive list):
M
C
U
@WebRTCventures
SFU example
• Selective Forwarding Unit
• Routes the correct stream to each user
• Still unique streams for each participant
(allows for layout changes on user side)
• More powerful and more modern option but
more complicated implementation
• Lower server CPU required but more variable
bandwidth (based on # of users)
• Possible to do end-to-end encryption
Media Servers offering SFU capability (not a comprehensive list):
S
F
U
@WebRTCventures
Scaling beyond single media server applications
Depends on the use case… What happens if we have 1000+ viewers?
For large broadcasting applications:
@WebRTCventures
S
F
U
S
F
U
S
F
U
Scaling beyond single media server applications
For large multiparty video conferencing applications:
@WebRTCventures
S
F
U
S
F
U
Video group calls with telephony integration
@WebRTCventures
MCU IP-PBX
Phone
caller
User
2
Web
Publishers
User
1
User
1
Web
Web
Publishers
SFU
User
2
Phone
caller
User
3
IP-PBX
User
1
MCU
SIP/RTP
SIP/RTP
RTP
WebRTC
Scaling beyond single media server applications
Large Video Conferencing Architecture considerations
• Multiparty video conferencing support?
• Integration of multiple channels
• Integration with VoIP legacy systems
• Recording/voicemail and speech to text
@WebRTCventures
Orchestration and Containers in WebRTC applications to
Achieve Horizontal Scalability
Challenges
• Decouple media server from application logic
• Stateful system complexities
• Autoscaling / Downscaling
• Overprovisioning
@WebRTCventures
WebRTC Scalability Autoscaling Rules
Planning your autoscaling rules
• Connections threshold for autoscaling
○ More accurate than CPU/bandwidth
• Maximum number of sessions/rooms per server
• Maximum users per room
○ To make sure we can predict
• Desired resources buffer for quick spikes:
○ 1, 2 or even 10 servers ready?
@WebRTCventures
Example of users joining media servers at a different pace
WebRTC scalability, stickiness and persistence
Sticky Sessions
• We need all users in a call to use the same media server
• Generally needs additional app logic build to distribute
traffic accordingly
• Approaches:
○ Cookie based load balanced sticky sessions
○ Direct routing through initial auth
Data Persistence
• All servers need to be aware of the current situation of the
connections
• DB or Cache based storage systems can be used for
storing sessions information and distribute traffic
• PubSub mechanisms can be a good addition to decouple
and scale independently
@WebRTCventures
Basic WebRTC Scalability and High
Availability Architecture
WebRTC load testing: testing your scalable application
@WebRTCventures
Approaches
• Build your own
• Open Source
• Third party platforms
What do we want to validate?
• Connections and media received/sent
• Jitter/Round Trip Time (RTT)/Packet Loss
• Acceptable Mean Opinion Score (MOS)
Application and Media Optimizations today
What can you do?
• Simulcast or SVC
• Audio detection
• Adaptive bitrate based on resolution
• Opus RED and DTX (Discontinuous Transmission)
@WebRTCventures
WebRTC SFU
SVC example
WebRTC SFU
Audio #1
Audio #2
Audio #4
Audio #3
A#3
A#2
A#1
Receiving Opus RED (Redundant Audio Data) example
Missing
packet
Application and Media Optimizations tomorrow
What will be recommended soon?
• AV1 video codec*
• Lyra V2 audio codec*
• Other ML optimizations (e.g: Noise Reduction or
packet loss concealment)
@WebRTCventures
*It is possible to use it but performance encoding is not great due to average hardware not being ready and some
browsers and devices don’t support it yet
Lyra v2 Google open source results: https://opensource.googleblog.com/2022/09/lyra-v2-a-better-faster-and-
more-versatile-speech-codec.html
Thank you!
Learn more about us:
https://webrtc.ventures
Follow us on Twitter:
@WebRTCventures
Experts in live video app development for:
Telehealth, Broadcasting, Contact Centers, and More!
@lbertogon
@arinsime
Contact us at team@webrtc.ventures

More Related Content

PDF
Kubernetes Deployment Strategies
PPT
Introduction To Webrtc
PDF
An Introduction to Apache Kafka
PPTX
NETCONF YANG tutorial
PPTX
WebRTC presentation
PDF
HAProxy TCP 모드에서 내부 서버로 Source IP 전달 방법
PDF
Kafka Streams: What it is, and how to use it?
Kubernetes Deployment Strategies
Introduction To Webrtc
An Introduction to Apache Kafka
NETCONF YANG tutorial
WebRTC presentation
HAProxy TCP 모드에서 내부 서버로 Source IP 전달 방법
Kafka Streams: What it is, and how to use it?

What's hot (20)

PPTX
Designing Apps for Runtime Fabric: Logging, Monitoring & Object Store Persist...
PPTX
Scaling Push Messaging for Millions of Netflix Devices
PPTX
Nat traversal in WebRTC context
PDF
An SFU/MCU integration for heterogeneous environments
PPTX
Apache tomcat
PDF
Monitoring Kubernetes with Prometheus
PDF
Can Apache Kafka Replace a Database?
PDF
ICE: The ultimate way of beating NAT in SIP
PDF
Flink 2.0: Navigating the Future of Unified Stream and Batch Processing
PPTX
An Introduction to Confluent Cloud: Apache Kafka as a Service
PDF
Highlights of WSO2 API Manager 4.0.0
PPTX
APACHE KAFKA / Kafka Connect / Kafka Streams
PDF
Spring Boot
PDF
Paul Angus - CloudStack Backup and Recovery Framework
PPTX
What is an SBC? A look at the role of the Session Border Controller
PDF
[DPE Summit] How Improving the Testing Experience Goes Beyond Quality: A Deve...
PPTX
Get Hands-On with NGINX and QUIC+HTTP/3
PDF
VLAN vs VXLAN
PDF
Loki - like prometheus, but for logs
Designing Apps for Runtime Fabric: Logging, Monitoring & Object Store Persist...
Scaling Push Messaging for Millions of Netflix Devices
Nat traversal in WebRTC context
An SFU/MCU integration for heterogeneous environments
Apache tomcat
Monitoring Kubernetes with Prometheus
Can Apache Kafka Replace a Database?
ICE: The ultimate way of beating NAT in SIP
Flink 2.0: Navigating the Future of Unified Stream and Batch Processing
An Introduction to Confluent Cloud: Apache Kafka as a Service
Highlights of WSO2 API Manager 4.0.0
APACHE KAFKA / Kafka Connect / Kafka Streams
Spring Boot
Paul Angus - CloudStack Backup and Recovery Framework
What is an SBC? A look at the role of the Session Border Controller
[DPE Summit] How Improving the Testing Experience Goes Beyond Quality: A Deve...
Get Hands-On with NGINX and QUIC+HTTP/3
VLAN vs VXLAN
Loki - like prometheus, but for logs
Ad

Similar to Architecting your WebRTC application for scalability, Arin Sime (20)

PDF
Architecting Low Latency Applications Alberto Gonzalez
PPTX
How to Architect your WebRTC application, Alberto Gonzalez and Arin Sime, Web...
PPTX
Bridging_WebRTC_with_SIP_Alberto_WebRTCventures_Cluecon2023_NoVideo.pptx
PDF
What is WebRTC and How does it work?
PDF
WebRTC Webinar & Q&A - W3C WebRTC JS API Test Platform & Updates from W3C Lis...
PPTX
Nubomedia: the cloud infrastructure for WebRTC and IMS multimedia real-time c...
PDF
WebRTC - Bridging Web and SIP Worlds
PPTX
WebSphere Liberty Rtcomm: WebRTC Middleware for the Enterprise
PDF
WebRTC standards update (13 Nov 2013)
PDF
The Show Must Go On! Using Kafka to Assure TV Signals Reach the Transmitters
PDF
WebRTC for Telco: Informa's WebRTC Global Summit Preconference
PPT
minor-project-1.ppt
PPTX
WebRTC Seminar Report
PDF
WebRTC from the service provider prism
PDF
WebRTC Infrastructure Design
PDF
From Stream to Screen: Real-Time Data Streaming to Web Frontends with Conflue...
PPTX
Recording and media manipulation of WebRTC streams
PDF
WebRTC And FreeSWITCH – What This Combination Means?
PDF
WebRTC DataChannels demystified
PDF
[AWS에서의 미디어 및 엔터테인먼트] 클라우드에서의 브로드캐스팅 서비스
Architecting Low Latency Applications Alberto Gonzalez
How to Architect your WebRTC application, Alberto Gonzalez and Arin Sime, Web...
Bridging_WebRTC_with_SIP_Alberto_WebRTCventures_Cluecon2023_NoVideo.pptx
What is WebRTC and How does it work?
WebRTC Webinar & Q&A - W3C WebRTC JS API Test Platform & Updates from W3C Lis...
Nubomedia: the cloud infrastructure for WebRTC and IMS multimedia real-time c...
WebRTC - Bridging Web and SIP Worlds
WebSphere Liberty Rtcomm: WebRTC Middleware for the Enterprise
WebRTC standards update (13 Nov 2013)
The Show Must Go On! Using Kafka to Assure TV Signals Reach the Transmitters
WebRTC for Telco: Informa's WebRTC Global Summit Preconference
minor-project-1.ppt
WebRTC Seminar Report
WebRTC from the service provider prism
WebRTC Infrastructure Design
From Stream to Screen: Real-Time Data Streaming to Web Frontends with Conflue...
Recording and media manipulation of WebRTC streams
WebRTC And FreeSWITCH – What This Combination Means?
WebRTC DataChannels demystified
[AWS에서의 미디어 및 엔터테인먼트] 클라우드에서의 브로드캐스팅 서비스
Ad

More from Alan Quayle (20)

PDF
What is a vCon?
PDF
Supercharging CPaaS Growth & Margins with Identity and Authentication, Aditya...
PPTX
Building a sub-second virtual ThunderDome: Considerations for mass scale sub-...
PDF
What makes a cellular IoT API great? Tobias Goebel
PDF
eSIM as Root of Trust for IoT security, João Casal
PPTX
CPaaS Conversational Platforms and Conversational Customer Service – The Expe...
PDF
Programmable Testing for Programmable Telcos, Andreas Granig
PDF
How to best maximize the conversation data stream for your business? Surbhi R...
PDF
Latest Updates and Experiences in Launching Local Language Tools, Karel Bourgois
PDF
What Everyone Needs to Know about Protecting the CPaaS Ecosystem from Unlawfu...
PDF
Master the Audience Experience Multiverse: AX Best Practices and Success Stor...
PDF
Open Source Telecom Software Survey 2022, Alan Quayle
PDF
OpenSIPS 3.3 – Messaging in the IMS and UC ecosystems. Bogdan-Andrei Iancu
PDF
TADS 2022 - Shifting from Voice to Workflow Management, Filipe Leitao
PDF
What happened since we last met TADSummit 2022, Alan Quayle
PDF
Stacuity - TAD Summit 2022 - Time to ditch the dumb-pipe, Mike Bromwich
PDF
AWA – a Telco bootstrapping product development: Challenges with dynamic mark...
PDF
Founding a Startup in Telecoms. The good, the bad and the ugly. João Camarate
PDF
How to bring down your own RTC platform. Sandro Gauci
PPTX
Radisys - Engage Digital - TADSummit Nov 2022
What is a vCon?
Supercharging CPaaS Growth & Margins with Identity and Authentication, Aditya...
Building a sub-second virtual ThunderDome: Considerations for mass scale sub-...
What makes a cellular IoT API great? Tobias Goebel
eSIM as Root of Trust for IoT security, João Casal
CPaaS Conversational Platforms and Conversational Customer Service – The Expe...
Programmable Testing for Programmable Telcos, Andreas Granig
How to best maximize the conversation data stream for your business? Surbhi R...
Latest Updates and Experiences in Launching Local Language Tools, Karel Bourgois
What Everyone Needs to Know about Protecting the CPaaS Ecosystem from Unlawfu...
Master the Audience Experience Multiverse: AX Best Practices and Success Stor...
Open Source Telecom Software Survey 2022, Alan Quayle
OpenSIPS 3.3 – Messaging in the IMS and UC ecosystems. Bogdan-Andrei Iancu
TADS 2022 - Shifting from Voice to Workflow Management, Filipe Leitao
What happened since we last met TADSummit 2022, Alan Quayle
Stacuity - TAD Summit 2022 - Time to ditch the dumb-pipe, Mike Bromwich
AWA – a Telco bootstrapping product development: Challenges with dynamic mark...
Founding a Startup in Telecoms. The good, the bad and the ugly. João Camarate
How to bring down your own RTC platform. Sandro Gauci
Radisys - Engage Digital - TADSummit Nov 2022

Recently uploaded (20)

PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
Machine learning based COVID-19 study performance prediction
PDF
Empathic Computing: Creating Shared Understanding
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
NewMind AI Monthly Chronicles - July 2025
PDF
Unlocking AI with Model Context Protocol (MCP)
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PDF
Electronic commerce courselecture one. Pdf
PDF
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
PPTX
Big Data Technologies - Introduction.pptx
PDF
Approach and Philosophy of On baking technology
PDF
KodekX | Application Modernization Development
PPTX
MYSQL Presentation for SQL database connectivity
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PPTX
A Presentation on Artificial Intelligence
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
Encapsulation theory and applications.pdf
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Digital-Transformation-Roadmap-for-Companies.pptx
The Rise and Fall of 3GPP – Time for a Sabbatical?
Machine learning based COVID-19 study performance prediction
Empathic Computing: Creating Shared Understanding
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
NewMind AI Monthly Chronicles - July 2025
Unlocking AI with Model Context Protocol (MCP)
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
Electronic commerce courselecture one. Pdf
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
Big Data Technologies - Introduction.pptx
Approach and Philosophy of On baking technology
KodekX | Application Modernization Development
MYSQL Presentation for SQL database connectivity
Mobile App Security Testing_ A Comprehensive Guide.pdf
Advanced methodologies resolving dimensionality complications for autism neur...
A Presentation on Artificial Intelligence
Network Security Unit 5.pdf for BCA BBA.
Encapsulation theory and applications.pdf

Architecting your WebRTC application for scalability, Arin Sime

  • 1. Architecting your WebRTC application for scalability Alberto Gonzalez and Arin Sime TADSummit Nov 8-9, 2022
  • 2. @WebRTCventures Alberto Gonzalez, CTO Arin Sime, CEO Agenda • Why it’s not easy to build scalable apps with WebRTC • Open Source vs CPaaS • So I just need an SFU or MCU to scale my app? • RTC orchestration and containers • Stickiness, persistence and load testing • Optimizations: App optimizations, media optimizations (e.g: codecs) How to Architect your WebRTC application for scalability!
  • 3. WebRTC is not quite this simple… • STUN/TURN servers • Application Signaling • Video codecs • Browser/Mobile Support • Recording • Group chat/scaling • Broadcasting @WebRTCventures
  • 4. 4 Ways to build your app… 1. To the standard, ie “build your own stack” 2. Unbundled WebRTC 3. Open source media servers 4. CPaaS – Communications Platform as a Service @WebRTCventures
  • 5. #1 – Building to the WebRTC Standard • Compiling webrtc lib • STUN/TURN servers • Application Signaling • Video/audio codecs • Group chat/scaling • Browser/Mobile Support • Recording/Other Add-on features • Can better utilize capabilities like WebCodecs, WebTransport and control low level details for specific use cases You must build and handle of the following – with great power comes great responsibility! https://webrtc.org @WebRTCventures
  • 6. #2 – Unbundling WebRTC May be appropriate when you find yourself saying “I wish WebRTC would do this instead…” @WebRTCventures Typical WebRTC media server Capture Encode Send Receive Decode Play WebAssembly media server Capture Web Codecs Web Transport Web Transport Web Codecs Play Diagram adapted from a presentation by Tsahi Levent-Levi on WebRTC Live, bloggeek.me Unbundled WebRTC - Allows use of other standards to have more control of the codecs, transport, as well as add in insertable streams
  • 7. #3 – Open Source Media Servers Media Servers will handle: • video/audio details • part or all of the signaling • Possibly STUN, TURN • Scaling capabilities • Could be SFUs or MCUs • Browser/Mobile support But you host/manage: • All infrastructure and updates Media Servers Your cloud servers @WebRTCventures
  • 8. #3 – Open Source Media Servers Media Servers Your cloud servers janus.conf.meetecho.com jitsi.org @WebRTCventures Popular examples: Pion.ly mediasoup.org LiveKit.io
  • 9. #4 – CPaaS – Communications Platforms Your Application servers A CPaaS will handle: • All WebRTC support / updates • Media Servers • STUN/TURN • Web/Mobile Support • Additional features like Recording, SMS, Voice/VOIP, Transcription, etc But you pay according to usage CPaaS @WebRTCventures
  • 10. #4 – CPaaS – Communications Platforms Your Application servers CPaaS @WebRTCventures Popular examples:
  • 11. It’s all about tradeoffs… WebRTC architecture WebRTC Standard Unbundled WebRTC Open Source Media Servers CPaaS Up front cost High High Medium Low Ongoing cost Low Low Low High Technical difficulty High Medium-High Medium Low Features included Low High* Medium High @WebRTCventures *Not really included, but you have flexibility to build your own on top of the underlying APIs And what about intellectual property? Also, what works for you today does not have to be your long term choice.
  • 13. SFUs or MCUs can help scale WebRTC MCU – Multipoint Control Unit • Handles mixing of video/audio streams in a central server so each participant only has one stream to deal with SFU – Selective Forwarding Unit • Each participant only connects to the SFU, but receives unique streams for each participant Either can add features beyond scaling • Recording • Broadcasting • Interface to other services like transcription or VoIP legacy systems @WebRTCventures
  • 14. MCU example • Multipoint Control Unit • Central server mixes all audio and video • Participants only gets one downloaded stream each for audio and video • MCU controls a composited layout of that video for everyone, which can be nice but also introduces latency • Heavy processing is required on a MCU, but offers more predictable bandwidth requirements Media Servers offering MCU capability (not a comprehensive list): M C U @WebRTCventures
  • 15. SFU example • Selective Forwarding Unit • Routes the correct stream to each user • Still unique streams for each participant (allows for layout changes on user side) • More powerful and more modern option but more complicated implementation • Lower server CPU required but more variable bandwidth (based on # of users) • Possible to do end-to-end encryption Media Servers offering SFU capability (not a comprehensive list): S F U @WebRTCventures
  • 16. Scaling beyond single media server applications Depends on the use case… What happens if we have 1000+ viewers? For large broadcasting applications: @WebRTCventures S F U S F U S F U
  • 17. Scaling beyond single media server applications For large multiparty video conferencing applications: @WebRTCventures S F U S F U
  • 18. Video group calls with telephony integration @WebRTCventures MCU IP-PBX Phone caller User 2 Web Publishers User 1 User 1 Web Web Publishers SFU User 2 Phone caller User 3 IP-PBX User 1 MCU SIP/RTP SIP/RTP RTP WebRTC Scaling beyond single media server applications
  • 19. Large Video Conferencing Architecture considerations • Multiparty video conferencing support? • Integration of multiple channels • Integration with VoIP legacy systems • Recording/voicemail and speech to text @WebRTCventures
  • 20. Orchestration and Containers in WebRTC applications to Achieve Horizontal Scalability Challenges • Decouple media server from application logic • Stateful system complexities • Autoscaling / Downscaling • Overprovisioning @WebRTCventures
  • 21. WebRTC Scalability Autoscaling Rules Planning your autoscaling rules • Connections threshold for autoscaling ○ More accurate than CPU/bandwidth • Maximum number of sessions/rooms per server • Maximum users per room ○ To make sure we can predict • Desired resources buffer for quick spikes: ○ 1, 2 or even 10 servers ready? @WebRTCventures Example of users joining media servers at a different pace
  • 22. WebRTC scalability, stickiness and persistence Sticky Sessions • We need all users in a call to use the same media server • Generally needs additional app logic build to distribute traffic accordingly • Approaches: ○ Cookie based load balanced sticky sessions ○ Direct routing through initial auth Data Persistence • All servers need to be aware of the current situation of the connections • DB or Cache based storage systems can be used for storing sessions information and distribute traffic • PubSub mechanisms can be a good addition to decouple and scale independently @WebRTCventures Basic WebRTC Scalability and High Availability Architecture
  • 23. WebRTC load testing: testing your scalable application @WebRTCventures Approaches • Build your own • Open Source • Third party platforms What do we want to validate? • Connections and media received/sent • Jitter/Round Trip Time (RTT)/Packet Loss • Acceptable Mean Opinion Score (MOS)
  • 24. Application and Media Optimizations today What can you do? • Simulcast or SVC • Audio detection • Adaptive bitrate based on resolution • Opus RED and DTX (Discontinuous Transmission) @WebRTCventures WebRTC SFU SVC example WebRTC SFU Audio #1 Audio #2 Audio #4 Audio #3 A#3 A#2 A#1 Receiving Opus RED (Redundant Audio Data) example Missing packet
  • 25. Application and Media Optimizations tomorrow What will be recommended soon? • AV1 video codec* • Lyra V2 audio codec* • Other ML optimizations (e.g: Noise Reduction or packet loss concealment) @WebRTCventures *It is possible to use it but performance encoding is not great due to average hardware not being ready and some browsers and devices don’t support it yet Lyra v2 Google open source results: https://opensource.googleblog.com/2022/09/lyra-v2-a-better-faster-and- more-versatile-speech-codec.html
  • 26. Thank you! Learn more about us: https://webrtc.ventures Follow us on Twitter: @WebRTCventures Experts in live video app development for: Telehealth, Broadcasting, Contact Centers, and More! @lbertogon @arinsime Contact us at team@webrtc.ventures

Editor's Notes

  • #9: Janus built in C, Jitsi built using Java, MediaSoup built with C++ and Pion uses Go
  • #12: Arin’s last slide - “and now Alberto will talk more about media servers and architectural use cases”
  • #13: As Arin mentioned, there are different alternatives when building your own WebRTC application. In most cases direct peer to peer communication is really not an option.. In this diagram, at the right, you can see a representation of how a 8 participants peer to peer network would look like. Without a intermediate media server helping us is a bit messy, and specially resource intensive! To reduce the amount of resources used at the edge, there are 2 popular architectures used to scaling this…
  • #14: MCU arch and SFU arch
  • #17: Now, how do we scale beyond a single MCU or SFU server? IT DEPENDS ON THE USE CASE Media processing operations are very CPU intensive! A XLarge AWS instance, for example, can’t handle more than a couple hundred of sd quality video streams. What happens if we have 1000 viewers? This is how the architecture in a very high level would look like And what about other use cases?
  • #18: So, in the case of larger video chat rooms, to have more than 50+ participants in the same room you might be reaching the limits of your infrastructure. It will be a good idea to use multiple MCU/SFU servers and each user can connect to them simultaneously! There are smarter ways to do this but this is an approach.
  • #19: And what about many concurrent connections or integrations with telephony systems like IP-PBX and so on. Well… that’s complicated but a simplified flow could look like this where we have web users connecting to an SFU/MCU from web or mobile and other users dialing in from the pstn at the right But there are potential challenges caused by differences in: the SIP implementation, supported resolutions, RTCP Muxing supported or not, different codecs or in case of H264 different profile level ID that define it. ICE (trickle) support…
  • #20: So what are the main considerations when deciding which of those architectures to use or implement? One is really evaluating the number of participants (small groups will make things easier). Also, do we need advance functionalities like recording? dial in pstn?
  • #21: Now how can we orchestrate this for horizontal scalability and handle 1000s of users calling concurrently? One proposed architecture could look like this diagram here where we have… The challenges we are trying to solve are:... stateful architectures: harder to handle crashes and scaling is difficult. We need to stick to the same server we were using before and reconnect. WebRTC doesn’t do caching like other stateless protocols like hls
  • #22: When scaling, if we want to be efficient we want to use auto scaling rules. This rules will… For example, in this charte we assume a connection threshold (this is the start of a new server) after 100 connections. And a server capacity of 400 connections. If our server start time is more than 60sec we wouldn’t have time to handle more than 5 new connections per second (or 300 connections in a minute spikes)
  • #23: Another 2 important topics when building scalable and high available webrtc solutions is sticky sessions and data persistence. By sticky sessions I mean connections that will be maintained so user always reach the same server. This is important because… Dayta persistence is what will allow us to distribute traffic between multiple concurrent services and to recover the session in case of a server failure
  • #24: After that, once we have our scalable infrastructure ready we will need to load test what we build. To do that it won’t be enough to simulate http requests but we will need to simulate real video and audio traffic. For that typically instances simulating participants are used to connect to the servers and send/receive media. In addition to verifying we are effectively connected and receiving the right number of connections we will need to evaluate the performance by capturing jitter/rtt/packet loss so we can obtain an acceptable quality score or emos. emos mean opinion score usually used to measure a/v quality
  • #25: Finally, there are also application and media optimizations you can use to have better quality and have a better experience when scaling. One way is using simulcast or SVC.. SVC is a technique that allows encoding a video stream once in multiple layers. The layers in SVC can be subtracted while maintaining the video, reducing its quality with the reduction of each layer (fps, resolution or snr layers) Another is just limiting the amount of video. Do you really need video? Some great tools just use audio (twitter spaces, clubhouse, slack huddle). In that case we can optimize a lot performance and reach a much larger audience! Or at least just get the video of the active participant using audio detection. Adapt bitrate based on video resolution, this can be done on the fly without renegotiation And for audio we have Opus RED and DTX, DTX shown in the diagram at the bottom right corner.. DTX simply eliminates audio when there is no audio at the other end…
  • #26: With that would almost conclude our presentation, but there are many more configuration options and optimizations that will be available in the future. Great teams of engineers are working on different fronts to surpass our current limitations. For example, AV1 and Lyra V2. AV1 has been around for a while already but most devices doesn’t support its hardware acceleration yet so it causes too high cpu usage as of today. Regarding Lyra v2: iOS and other embedded platforms are not supported at this time, but this may change in the future. You can see how lyra achieves same quality with much lower bitrates! And, since before we talked about Opus DTX and how we stop sending audio when is not necessary…Some improvements can be made for better quality. The process of dealing with the missing packets is called packet loss concealment (PLC). The receiver’s PLC module is responsible for creating audio (or video) to fill in the gaps created by packet losses, excessive jitter or temporary network glitches, all three of which result in an absence of data. To realistically continue short speech segments enabling it to fully synthesize the raw waveform of missing speech
  • #27: And with that, here concludes our presentation about architecting your WebRTC application for scalability. I really hope you enjoyed and learned from this! And if you are interested about this topics visit us or follow us on Twitter! Thank you so much for watching!