Try Live Demo

Scaling WebRTC streaming is one of the powerful features of Ant Media Server and you could scale up to 30K viewers easily in one minute installation with CloudFormation utility. This is 2nd part of the post series about “how to scale Ant Media Server to 100,000 viewers” and you can read the previous part of this tutorial to refresh your mind from the following link: Part I.

Scaling WebRTC Streaming

As we’ve seen in the previous part, performing a load test with 10K viewers was surprisingly easy. As a next step, we will talk about how to do that with 30K viewers. In the next series of the blog, we will be talking about how to set and reach up to 50K and 100K viewers step by step with performing load test, therefore please bear with us.

In the test environment, we are going to use the same number of Load Balancers and Databases, and only for this time, we’re going to increase the number of edge instances from 10 to 25, and the number of Loads instances from 10 to 30. Have a look at that here for a quick refresher.

How Many Instances You Need?

So let’s gets started! We have set up 25 Edge servers and 1 Origin server for 30K viewers testing and we used Ant Media Cost Calculator to define that before setting it up. Estimating an overall cost and configuration based on the number of viewers and broadcasters / publishers is a common issue for developers. To handle this issue, Ant Media Cost Calculator can help you. You can enter total number of broadcasts, viewers and then it shows you how many instances you need and how much it will cost.

https://antmedia.io/cost-calculator

Here is an example.  We choose the Cloud Provider, Instance Type, number of broadcasts and number of viewers. Then it shows us how many instances we need and their estimated cost.

antmedia-cost-calculator

Quick setup in 1 Minute with CloudFormation

We use AWS’s CloudFormation service to set up the cluster. The thing that we love best about this tool is that we complete the setup in one minute. To mention briefly, AWS CloudFormation is a configuration orchestration tool that allows you to codify your infrastructure and automate your deployments. Keep in mind that we’re also preparing a blog post about using our CloudFormation template to set up clusters in just a few clicks. Nevertheless, if you are eager to try, here it is the Cloud Formation template for you.

https://raw.githubusercontent.com/ant-media/Scripts/master/cloudformation/antmedia-aws-autoscale-template.yaml

Improved Performance

We were already expecting a performance boost when optimizing our 2.1 version. However, at the end of the tests, it was quite surprising that our performance was increased about %35~ more than the previous version v2.0. In other words, Ant Media Server uses %35 less CPU to handle the same number of viewers.

Scaling WebRTC Streaming screen

Here is the output of the monitor tool. It seems that there is no even a single connection drop for the viewers. It’s exactly 30001.

So this optimization will make our product more efficient than before allowing our customers to have much more capacity to handle in their current configuration.

Ant Media Server Dashboard - Scaling WebRTC Streaming

Scaling WebRTC Streaming

Perfect Audio and Video Timing

Finally, when it comes to “perfect timing”, we send audio at 20ms and video at 40ms synchronously without any problem. Here is the percentile graphics.

WebRTC Streaming

Our next blog will be about how Ant Media Server will handle 50K and 100K. Stay tuned!
If you have any questions, please just drop a line to contact (at) antmedia.io

You may want to also check out Mass Broadcasting Made Easy with Ant Media WebRTC Solution – 70K Unlocked!


Ahmet Oguz Mermerkaya

Oguz is the co-founder of Ant Media. His tech stack includes VxWorks, UML, Rhapsody in C++. Java, OSGi, Swing, JSF, Web, PHP, FFmpeg API, Native WebRTC, Java EE, Hibernate, Spring, MongoDB, MySQL, Angular, JavaScript, HTML5, Android (Native) and iOS (Native). Oguz is one of the writers of "Merhaba Android", one of the first books published in Turkey about Android app programming. His second book is about HTML5 & CSS3. He has attended several conferences and universities talking about Android, business life and technical issues. He is a member of the GDG Community and also the founder of GDG Ankara.