Bandwidth management for WebRTC servers

Bandwidth management for WebRTC servers
21 March 2023
In today’s digital world, Web Real-Time Communication (WebRTC) technology is a popular solution for developers who want to create real-time applications such as video conferencing, and live streaming. However, the success of these applications depends on the ability of WebRTC media servers to perfect bandwidth usage while keeping predictable costs. In this blog, we will explore the importance of bandwidth management for WebRTC servers, how to control costs, and make timebound predictions for usage fluctuations.

Table of Contents

Optimizing bandwidth for WebRTC servers

Optimizing bandwidth usage is crucial for WebRTC servers as it directly affects the performance of real-time applications. For instance, high-bandwidth usage can lead to latency, packet loss, and poor audio and video quality. On the other hand, low-bandwidth usage can result in a choppy and inconsistent user experience. Therefore, it is essential to perfect bandwidth usage to ensure a seamless real-time experience for users.

One way to perfect usage is to implement a bandwidth management system that controls the amount of bandwidth distributed to each user or device. This can be achieved through various techniques such as congestion control, media prioritization and scalable video coding.

Congestion control

In the context of WebRTC servers, congestion control is particularly important because real-time communication applications require a constant flow of data to ensure a seamless user experience. If too much data is sent at once, the network can become congested, leading to delays, packet loss, and poor audio and video quality.

To implement congestion control in WebRTC, the server uses an algorithm that dynamically adjusts the data rate based on current network conditions. The algorithm uses feedback from the network to decide the proper data rate and adjust it in real time. This feedback includes metrics such as packet loss, round-trip time, and available bandwidth.

The goal of congestion control is to ensure that the network is used efficiently while minimizing the risk of congestion. It is important to note that congestion control is not just about limiting the amount of data sent but also ensuring that data is sent at the proper time. For example, the algorithm may delay sending data if the network is congested to avoid worsening the problem.

Media prioritization

Ways to implement media prioritization in WebRTC

1. DiffSery

There are several ways to implement media prioritization in WebRTC. One common technique is to use Differentiated Services (DiffServ) to mark audio and video packets as high priority. DiffServ is a protocol that allows network devices to prioritize traffic based on the type of service. By marking audio and video packets as high priority, the server can ensure that they are transmitted before other types of data.

2. Layering

Another technique used in media prioritization is to use a technique called layering. This involves encoding video data in multiple layers, with each layer having a different quality and bitrate. The server can then prioritize the transmission of high-quality layers, which have more valuable information while delaying the transmission of lower-quality layers until there is sufficient bandwidth available.

Scalable Video Coding

Scalable Video Coding (SVC) is a technique used in video compression to allow video streams to be transmitted over a range of network conditions without sacrificing quality. SVC achieves this by dividing the video stream into multiple layers, each with its own resolution and bitrate, and encoding each layer independently.

Improving video streaming quality with SVC

In traditional video coding, a video stream is encoded into a single layer, and the decoder must decode the entire stream to display the video. This means that if network conditions deteriorate, the video quality will suffer as the decoder is forced to drop packets to keep up with the transmission rate.

SVC solves this problem by breaking the video stream into multiple layers, each of which can be decoded independently. This means that if network conditions deteriorate, the decoder can drop the low-quality layers and still display the video, albeit at a lower quality. Similarly, if network conditions improve, the decoder can request higher-quality layers to improve the video quality.

The ability to adjust the video quality dynamically based on network conditions makes SVC particularly useful for real-time communication applications that use WebRTC technology. In these applications, supporting a high-quality user experience is critical, and SVC allows the server to adjust the video quality in real-time to ensure that users receive the best possible experience.

Optimizing video streaming across different devices with SVC

Another advantage of SVC is that it allows the video stream to be adapted to different devices with different capabilities. For example, a mobile device may have a lower resolution screen and a slower processor than a desktop computer. By supplying multiple layers of the video stream, the server can tailor the video quality to the capabilities of the device, ensuring that users receive the best possible experience regardless of the device they are using.

Congestion Control, Media Prioritization, and Scalable Video Coding are just a set of examples you could implement to optimize bandwidth usage for your WebRTC application. Aside from these and other techniques to optimize bandwidth usage for your user’s quality perspective, there’s one more reason optimizing bandwidth usage for Real-Time Communication applications may be crucial: cost control.

Costs and network quality

Excessive bandwidth usage can lead to increased costs, which can affect the profitability of your applications. Therefore, it may be essential to optimize your bandwidth usage as mentioned earlier in this blog.

Optimizing technical aspects in your WebRTC setup are not the only points you should take into consideration when optimizing bandwidth usage. The flip side of the coin is to do due diligence on your compute and connectivity provider. Some providers offer more control over bandwidth usage and costs, while others supply a more one-size-fits-all approach to both bandwidth usage and pricing, as well as the connectivity quality and connected networks.

As WebRTC servers, especially media servers have high bandwidth demands, egress charges can become costly when you scale up. And while Ingress traffic is usually free with major cloud providers as soon as your traffic leaves their ecosystem you may be charged 12x per GB of egress as what you would pay with other providers. With it being a growing pain for various companies such as Apple and Netflix, it pays off to thoroughly investigate the potential egress charges.

WebRTC performance is affected by your provider’s Network Quality

Costs are one of the parts of due diligence you should be doing while selecting providers as optimizing network quality is crucial for ensuring a smooth and reliable WebRTC service. Jitter, latency, and packet loss can all affect the user experience and result in communication issues. To ensure high network quality, it is important to consider the following:

1. Test network quality

Testing network quality using a looking glass tool is a crucial step in finding any potential issues. Providers should conduct a live Proof of Concept (PoC) to test the network over a period before signing a contract.’s Looking Glass tool supplies relevant information on network quality that can be used to assess the suitability of a provider.

2. Check physical and network presence

Providers should verify the physical and network presence of their chosen provider. While global presence is important, it’s not the only factor to consider. The internet is routed through physical cables and the speed of light cannot be beaten. Peering connections between providers can also affect network quality. Providers should figure out which ISPs their customers use in their markets and check whether their chosen provider can reach those providers without scenic routing.

3. Monitor network performance

Providers should continuously monitor network performance to find any issues that may arise. This includes monitoring jitter, latency, and packet loss to ensure that the network is performing as expected. Providers can use monitoring tools to track network performance and set up alerts to let them know of any issues.
By prioritizing network quality, providers can ensure that their WebRTC service is reliable and delivers a high-quality user experience. This is particularly important for engineers who need to optimize bandwidth usage, control costs, and ensure predictability in their WebRTC servers.
Main Take-Aways

There are various angles to investigate for optimizing bandwidth for your WebRTC servers. On the one hand your engineering team may want to apply optimizations in your code to limit excess bandwidth usage, while on the other hand when selecting a partner for infrastructure it is important to do your due diligence both on network quality as well as its costs structure.