Architecting Low Latency Applications Alberto Gonzalez

Alberto González Trastoy
Alberto González TrastoySenior Software Engineer
Architecting Low Latency
Applications
Alberto Gonzalez Trastoy
WSAS 2022
Nov 15, 2022
@WebRTCventures
Agenda
• WebRTC, a protocol to connect them all
• Why it’s not easy to build with WebRTC
• Open Source vs CPaaS
• Basic architectures: SFUs and MCUs
• Scalability
• Optimizations
• Conclusions
Architecting Low Latency Applications!
WebRTC
An open framework for the web that enables Real-Time Communications (RTC)
capabilities in apps and in the browser. In 2021 WebRTC got officially standardized.
@WebRTCventures
Some companies using WebRTC Latency VS other low latency protocols
WebRTC in 2 steps
In theory we just need:
1) Capture/Manage media (MediaStream API)
const stream = await
navigator.mediaDevices.getUserMedia({audi
o: true, video: true});
localStream = stream;
2) Send /Receive media (RTCPeerConnection API)
pc1 = new
RTCPeerConnection(configuration);
const offer = await
pc1.createOffer(offerOptions);
await pc1.setLocalDescription(offer);
localStream.getTracks().forEach(track =>
pc1.addTrack(track, localStream));
//send offer/receive answer and
//receive incoming media
@WebRTCventures
But WebRTC implementations aren’t that simple…
@WebRTCventures
Many pieces are left for the
implementer to figure out and its
scalability is complex…
WebRTC Scaling Challenges
@WebRTCventures
Mesh network
WebRTC Media Servers
Media Servers will handle:
• Video/audio details
• Scaling capabilities
• Browser/Mobile support
Media
Servers
Your cloud servers
@WebRTCventures
Relationship between # client side
connections (y) and total participants (x)
- Blue line representing the connection
growth using a mesh network
- Yellow and red lines representing other
popular media server architectures
Open Source Media Servers
Media
Servers
Your cloud servers
janus.conf.meetecho.com
jitsi.org
@WebRTCventures
Popular examples:
Pion.ly
mediasoup.org
livekit.io
Types of WebRTC Media Servers: MCUs
• Multipoint Control Unit
• Central server mixes all audio and video
• Each participant only gets one downloaded stream
each for audio and video
• Heavy processing required on MCU, but more
predictable bandwidth requirements
Media Servers offering MCU capability (not a comprehensive list):
M
C
U
@WebRTCventures
Types of WebRTC Media Servers: SFUs
• Selective Forwarding Unit
• Routes the correct stream to each user
• More powerful and more modern option but
more complicated implementation
• Lower CPU requirements but more variable
bandwidth required (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
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
For large multiparty video conferencing applications:
@WebRTCventures
S
F
U
S
F
U
Orchestration and Containers in WebRTC applications to
Achieve Horizontal Scalability
Challenges
• Complex and coupled media server and application logic
• Stateful system complexities
• Autoscaling
• 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
• Backup resources ready for 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
• Some 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
Application and Media Optimizations
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
Future Application and Media Optimizations
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
Summary
• Focus on your specific use case needs. Review if you really need to use low latency streaming.
• Don’t underestimate the importance of a efficient scalable and high available WebRTC infrastructure
• Decide where you are willing to compromise
• Optimize and leverage the latest WebRTC capabilities
@WebRTCventures
Thank you!
Learn more about us:
https://webrtc.ventures
Follow us on Twitter:
@WebRTCventures
@lbertogon
Now you hold the Ring of Power
Questions?
Experts in live video app development for:
Telehealth, Broadcasting, Contact Centers, and More!
1 of 19

Recommended

Architecting your WebRTC application for scalability, Arin Sime by
Architecting your WebRTC application for scalability, Arin SimeArchitecting your WebRTC application for scalability, Arin Sime
Architecting your WebRTC application for scalability, Arin SimeAlan Quayle
179 views26 slides
WebRTC Seminar Report by
WebRTC  Seminar ReportWebRTC  Seminar Report
WebRTC Seminar Reportsrinivasa teja
2.1K views43 slides
Bridging_WebRTC_with_SIP_Alberto_WebRTCventures_Cluecon2023_NoVideo.pptx by
Bridging_WebRTC_with_SIP_Alberto_WebRTCventures_Cluecon2023_NoVideo.pptxBridging_WebRTC_with_SIP_Alberto_WebRTCventures_Cluecon2023_NoVideo.pptx
Bridging_WebRTC_with_SIP_Alberto_WebRTCventures_Cluecon2023_NoVideo.pptxAlberto González Trastoy
6 views17 slides
WebRTC by
WebRTCWebRTC
WebRTCVijay Dhama
15.6K views32 slides
How to Architect your WebRTC application, Alberto Gonzalez and Arin Sime, Web... by
How to Architect your WebRTC application, Alberto Gonzalez and Arin Sime, Web...How to Architect your WebRTC application, Alberto Gonzalez and Arin Sime, Web...
How to Architect your WebRTC application, Alberto Gonzalez and Arin Sime, Web...Alan Quayle
192 views21 slides
What is WebRTC and How does it work? by
What is WebRTC and How does it work?What is WebRTC and How does it work?
What is WebRTC and How does it work?SandipPatel533958
4 views8 slides

More Related Content

Similar to Architecting Low Latency Applications Alberto Gonzalez

WebRTC. Yet Another Overview, for IT Technicians. by
WebRTC. Yet Another Overview, for IT Technicians.WebRTC. Yet Another Overview, for IT Technicians.
WebRTC. Yet Another Overview, for IT Technicians.Vladimir Beloborodov
1.4K views18 slides
WebRTC DataChannels demystified by
WebRTC DataChannels demystifiedWebRTC DataChannels demystified
WebRTC DataChannels demystifiedVictor Pascual Ávila
106.5K views41 slides
WebRTC standards update (13 Nov 2013) by
WebRTC standards update (13 Nov 2013)WebRTC standards update (13 Nov 2013)
WebRTC standards update (13 Nov 2013)Victor Pascual Ávila
2.4K views35 slides
WebRTC presentation by
WebRTC presentationWebRTC presentation
WebRTC presentationVeselin Pizurica
4.1K views27 slides
kurento-nubomedia-first-steps-v1 by
kurento-nubomedia-first-steps-v1kurento-nubomedia-first-steps-v1
kurento-nubomedia-first-steps-v1Luis Lopez
2.8K views34 slides

Similar to Architecting Low Latency Applications Alberto Gonzalez(20)

WebRTC. Yet Another Overview, for IT Technicians. by Vladimir Beloborodov
WebRTC. Yet Another Overview, for IT Technicians.WebRTC. Yet Another Overview, for IT Technicians.
WebRTC. Yet Another Overview, for IT Technicians.
kurento-nubomedia-first-steps-v1 by Luis Lopez
kurento-nubomedia-first-steps-v1kurento-nubomedia-first-steps-v1
kurento-nubomedia-first-steps-v1
Luis Lopez2.8K views
Kurento - FI-WARE Bootcamp by Ivan Gracia
Kurento - FI-WARE BootcampKurento - FI-WARE Bootcamp
Kurento - FI-WARE Bootcamp
Ivan Gracia1.5K views
WebRTC Webinar & Q&A - W3C WebRTC JS API Test Platform & Updates from W3C Lis... by Amir Zmora
WebRTC Webinar & Q&A - W3C WebRTC JS API Test Platform & Updates from W3C Lis...WebRTC Webinar & Q&A - W3C WebRTC JS API Test Platform & Updates from W3C Lis...
WebRTC Webinar & Q&A - W3C WebRTC JS API Test Platform & Updates from W3C Lis...
Amir Zmora212 views
WebRTC for Telco: Informa's WebRTC Global Summit Preconference by Tsahi Levent-levi
WebRTC for Telco: Informa's WebRTC Global Summit PreconferenceWebRTC for Telco: Informa's WebRTC Global Summit Preconference
WebRTC for Telco: Informa's WebRTC Global Summit Preconference
Tsahi Levent-levi20.6K views
Kranky Geek WebRTC 2015 - The future of ORTC with WebRTC by Kranky Geek
Kranky Geek WebRTC 2015 - The future of ORTC with WebRTCKranky Geek WebRTC 2015 - The future of ORTC with WebRTC
Kranky Geek WebRTC 2015 - The future of ORTC with WebRTC
Kranky Geek817 views
Media processing with serverless architecture by Kensaku Komatsu
Media processing with serverless architectureMedia processing with serverless architecture
Media processing with serverless architecture
Kensaku Komatsu867 views
Analysis of video quality and end-to-end latency in WebRTC by Boni García
Analysis of video quality and end-to-end latency in WebRTCAnalysis of video quality and end-to-end latency in WebRTC
Analysis of video quality and end-to-end latency in WebRTC
Boni García1.7K views
Recording and media manipulation of WebRTC streams by Luis Lopez
Recording and media manipulation of WebRTC streamsRecording and media manipulation of WebRTC streams
Recording and media manipulation of WebRTC streams
Luis Lopez3.2K views
Which is Better: gRPC or WebSocket? A Comprehensive Comparison by Tien Nguyen
Which is Better: gRPC or WebSocket? A Comprehensive ComparisonWhich is Better: gRPC or WebSocket? A Comprehensive Comparison
Which is Better: gRPC or WebSocket? A Comprehensive Comparison
Tien Nguyen35 views
WebRTC Infrastructure Design by Neeraj Chandra
WebRTC Infrastructure DesignWebRTC Infrastructure Design
WebRTC Infrastructure Design
Neeraj Chandra166 views
WebRTC - Bridging Web and SIP Worlds by IMTC
WebRTC - Bridging Web and SIP WorldsWebRTC - Bridging Web and SIP Worlds
WebRTC - Bridging Web and SIP Worlds
IMTC1.4K views

Recently uploaded

Sprint 226 by
Sprint 226Sprint 226
Sprint 226ManageIQ
8 views18 slides
Fleet Management Software in India by
Fleet Management Software in India Fleet Management Software in India
Fleet Management Software in India Fleetable
12 views1 slide
Advanced API Mocking Techniques by
Advanced API Mocking TechniquesAdvanced API Mocking Techniques
Advanced API Mocking TechniquesDimpy Adhikary
23 views11 slides
Navigating container technology for enhanced security by Niklas Saari by
Navigating container technology for enhanced security by Niklas SaariNavigating container technology for enhanced security by Niklas Saari
Navigating container technology for enhanced security by Niklas SaariMetosin Oy
14 views34 slides
AI and Ml presentation .pptx by
AI and Ml presentation .pptxAI and Ml presentation .pptx
AI and Ml presentation .pptxFayazAli87
12 views15 slides
2023-November-Schneider Electric-Meetup-BCN Admin Group.pptx by
2023-November-Schneider Electric-Meetup-BCN Admin Group.pptx2023-November-Schneider Electric-Meetup-BCN Admin Group.pptx
2023-November-Schneider Electric-Meetup-BCN Admin Group.pptxanimuscrm
15 views19 slides

Recently uploaded(20)

Sprint 226 by ManageIQ
Sprint 226Sprint 226
Sprint 226
ManageIQ8 views
Fleet Management Software in India by Fleetable
Fleet Management Software in India Fleet Management Software in India
Fleet Management Software in India
Fleetable12 views
Advanced API Mocking Techniques by Dimpy Adhikary
Advanced API Mocking TechniquesAdvanced API Mocking Techniques
Advanced API Mocking Techniques
Dimpy Adhikary23 views
Navigating container technology for enhanced security by Niklas Saari by Metosin Oy
Navigating container technology for enhanced security by Niklas SaariNavigating container technology for enhanced security by Niklas Saari
Navigating container technology for enhanced security by Niklas Saari
Metosin Oy14 views
AI and Ml presentation .pptx by FayazAli87
AI and Ml presentation .pptxAI and Ml presentation .pptx
AI and Ml presentation .pptx
FayazAli8712 views
2023-November-Schneider Electric-Meetup-BCN Admin Group.pptx by animuscrm
2023-November-Schneider Electric-Meetup-BCN Admin Group.pptx2023-November-Schneider Electric-Meetup-BCN Admin Group.pptx
2023-November-Schneider Electric-Meetup-BCN Admin Group.pptx
animuscrm15 views
BushraDBR: An Automatic Approach to Retrieving Duplicate Bug Reports by Ra'Fat Al-Msie'deen
BushraDBR: An Automatic Approach to Retrieving Duplicate Bug ReportsBushraDBR: An Automatic Approach to Retrieving Duplicate Bug Reports
BushraDBR: An Automatic Approach to Retrieving Duplicate Bug Reports
Myths and Facts About Hospice Care: Busting Common Misconceptions by Care Coordinations
Myths and Facts About Hospice Care: Busting Common MisconceptionsMyths and Facts About Hospice Care: Busting Common Misconceptions
Myths and Facts About Hospice Care: Busting Common Misconceptions
JioEngage_Presentation.pptx by admin125455
JioEngage_Presentation.pptxJioEngage_Presentation.pptx
JioEngage_Presentation.pptx
admin1254556 views
Top-5-production-devconMunich-2023.pptx by Tier1 app
Top-5-production-devconMunich-2023.pptxTop-5-production-devconMunich-2023.pptx
Top-5-production-devconMunich-2023.pptx
Tier1 app8 views
FIMA 2023 Neo4j & FS - Entity Resolution.pptx by Neo4j
FIMA 2023 Neo4j & FS - Entity Resolution.pptxFIMA 2023 Neo4j & FS - Entity Resolution.pptx
FIMA 2023 Neo4j & FS - Entity Resolution.pptx
Neo4j12 views
Airline Booking Software by SharmiMehta
Airline Booking SoftwareAirline Booking Software
Airline Booking Software
SharmiMehta6 views
Ports-and-Adapters Architecture for Embedded HMI by Burkhard Stubert
Ports-and-Adapters Architecture for Embedded HMIPorts-and-Adapters Architecture for Embedded HMI
Ports-and-Adapters Architecture for Embedded HMI
Burkhard Stubert21 views
Bootstrapping vs Venture Capital.pptx by Zeljko Svedic
Bootstrapping vs Venture Capital.pptxBootstrapping vs Venture Capital.pptx
Bootstrapping vs Venture Capital.pptx
Zeljko Svedic12 views
Introduction to Git Source Control by John Valentino
Introduction to Git Source ControlIntroduction to Git Source Control
Introduction to Git Source Control
John Valentino5 views

Architecting Low Latency Applications Alberto Gonzalez

  • 1. Architecting Low Latency Applications Alberto Gonzalez Trastoy WSAS 2022 Nov 15, 2022
  • 2. @WebRTCventures Agenda • WebRTC, a protocol to connect them all • Why it’s not easy to build with WebRTC • Open Source vs CPaaS • Basic architectures: SFUs and MCUs • Scalability • Optimizations • Conclusions Architecting Low Latency Applications!
  • 3. WebRTC An open framework for the web that enables Real-Time Communications (RTC) capabilities in apps and in the browser. In 2021 WebRTC got officially standardized. @WebRTCventures Some companies using WebRTC Latency VS other low latency protocols
  • 4. WebRTC in 2 steps In theory we just need: 1) Capture/Manage media (MediaStream API) const stream = await navigator.mediaDevices.getUserMedia({audi o: true, video: true}); localStream = stream; 2) Send /Receive media (RTCPeerConnection API) pc1 = new RTCPeerConnection(configuration); const offer = await pc1.createOffer(offerOptions); await pc1.setLocalDescription(offer); localStream.getTracks().forEach(track => pc1.addTrack(track, localStream)); //send offer/receive answer and //receive incoming media @WebRTCventures
  • 5. But WebRTC implementations aren’t that simple… @WebRTCventures Many pieces are left for the implementer to figure out and its scalability is complex…
  • 7. WebRTC Media Servers Media Servers will handle: • Video/audio details • Scaling capabilities • Browser/Mobile support Media Servers Your cloud servers @WebRTCventures Relationship between # client side connections (y) and total participants (x) - Blue line representing the connection growth using a mesh network - Yellow and red lines representing other popular media server architectures
  • 8. 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. Types of WebRTC Media Servers: MCUs • Multipoint Control Unit • Central server mixes all audio and video • Each participant only gets one downloaded stream each for audio and video • Heavy processing required on MCU, but more predictable bandwidth requirements Media Servers offering MCU capability (not a comprehensive list): M C U @WebRTCventures
  • 10. Types of WebRTC Media Servers: SFUs • Selective Forwarding Unit • Routes the correct stream to each user • More powerful and more modern option but more complicated implementation • Lower CPU requirements but more variable bandwidth required (based on # of users) • Possible to do end-to-end encryption Media Servers offering SFU capability (not a comprehensive list): S F U @WebRTCventures
  • 11. Scaling beyond single media server 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
  • 12. Scaling beyond single media server For large multiparty video conferencing applications: @WebRTCventures S F U S F U
  • 13. Orchestration and Containers in WebRTC applications to Achieve Horizontal Scalability Challenges • Complex and coupled media server and application logic • Stateful system complexities • Autoscaling • Overprovisioning • @WebRTCventures
  • 14. 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 • Backup resources ready for spikes: ○ 1, 2 or even 10 servers ready? @WebRTCventures Example of users joining media servers at a different pace
  • 15. 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 • Some 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
  • 16. Application and Media Optimizations 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
  • 17. Future Application and Media Optimizations 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
  • 18. Summary • Focus on your specific use case needs. Review if you really need to use low latency streaming. • Don’t underestimate the importance of a efficient scalable and high available WebRTC infrastructure • Decide where you are willing to compromise • Optimize and leverage the latest WebRTC capabilities @WebRTCventures
  • 19. Thank you! Learn more about us: https://webrtc.ventures Follow us on Twitter: @WebRTCventures @lbertogon Now you hold the Ring of Power Questions? Experts in live video app development for: Telehealth, Broadcasting, Contact Centers, and More!