Popular cloud hosting DigitalOcean has recently launched its new marketplace selling preconfigured images that can help to quickly deploy an application server. It’s much like AWS, but DO is for those already using this provider’s services. Let’s see how to deploy a simple server for WebRTC streaming with a DO account for a $10/month fee based on Flashphoner WebCallServer and how such a server can be of use.
Deployment
Enter the DO account, choose the Flashphoner WebCallServer image in Marketplace and press “Create Flashphoner Web Call Server Droplet”
Choose the server performance and the pricing plan. DO will automatically offer a mid-segment product, but we are interested in the minimum price
Choose the datacenter location region, for example, Frankfurt
Choose the authentication type, for example, one-time password
Specify the number of servers (we are interested in one server for now) and name the server. This name will be registered among other locations in /etc/hostname
Press “Create droplet”
As soon as the server is created, it will start automatically. Now we can connect to it through SSH, and modify the password if one-time password has been chosen as authentication method. A short description of Flashphoner WebCallServer with links to documentation will be displayed in the console
“This Is a Test. Can You See Me?”
By the time Flashphoner WebCallServer is started, it is in full ready-to-work mode, a 30-day trial license is activated automatically. Web interface is used to test the key functions. We will just check the publication and WebRTC stream playback.
Open in the browser the page https://droplet_ip:8444/admin/. The server is shipped with self-signed certificate by default; therefore we will need to confirm security exception. The certificates can be replaced later with your own. Enter the username and password (demo by default)
Choose the Two-Way Streaming example in the sidebar, press “Connect”, then “Publish”. To play the stream press “Play”
For a Handful of Dollars
What can a $10/month server do as hardware platform for WebRTC streaming? Let’s see what Digital Ocean offers in terms of processor
lscpu
and memory
free -h
By running load tests on the server, we can see that the server performance capabilities are not so small.
As an example, we are going to publish one stream sample and see how many users will be able to publish this stream simultaneously not exceeding 90% of the processor resources:
Resolution | Bitrate, Kbps | Number of publications | Number of viewers |
360p | 1300 | 1 | 70 |
480p | 1800 | 1 | 70 |
720p | 3000 | 1 | 50 |
With several simultaneous publications the maximum number of processed streams remains the same; when 7 streams are published, up to 10 viewers are able to subscribe to each.
Suppose we need to transcode the stream on the server in order to reduce the resolution or align the FPS. To do this, we are going to check the maximum number of publications:
Resolution | Bitrate, Kbps | Number of streams |
360p | 1300 | 5 |
480p | 1800 | 3 |
720p | 3000 | 2 |
In this manner, the server with the lowest price on DO with the parameters 1 CPU core, 2 Gb RAM, 2 TB traffic is suitable not only for testing WebRTC streaming but also for small projects. For example, it is possible to
- deliver a stream via WebRTC from an IP camera in order to ensure basic in-house video surveillance;
- organize a webinar for a small company staff;
- deploy your own internet-radio (audio streams require less processor resources).
Besides, this server can be viewed as reference platform for scaling estimation. This is what we will deal with further on.
“I Deserve More!”
For the most part, the rules are quite simple: there’s no such thing as too many cores as well as too much memory. Depending on the intended number of users, DO configuration recommendations will be the following:
Number of users | vCPUs | RAM, Gb | Traffic, TB | Use case |
up to 200 | 4 | 8 | 5 | Video surveillance system |
up to 500 | 8 | 16 | 6 | Webinars |
up to 1000 | 16 | 64 | 9 | Video chat |
up to 2000 | 20 | 96 | 10 | HD video streaming |
If further increase in number of users is planned, we will need to deploy the CDN projecting 1 Edge server per 2000 users. Suppose we need to deliver an HD video, the intended number of viewers is 10000. In this case, 2 Origin servers for publishing and 5 Edge servers for viewing will be required
Setup example:
- Origin 1
cdn_enabled=true cdn_ip=origin1.flashponer.com cdn_nodes_resolve_ip=false cdn_role=origin
- Origin 2
cdn_enabled=true cdn_ip=origin2.flashponer.com сdn_point_of_entry=origin1.flashponer.com cdn_nodes_resolve_ip=false cdn_role=origin
- Edge 1 – Edge 5 (here we change only the server address in the cdn_ip parameter)
cdn_enabled=true cdn_ip=edge1.flashphoner.com cdn_point_of_entry=origin1.flashponer.com cdn_nodes_resolve_ip=false cdn_role=edge
CDN can also be of use if the users are geographically dispersed. For example, our target audiences are based in Europe and America
Setup example:
- Origin EU
cdn_enabled=true cdn_ip=origin_eu.flashponer.com cdn_nodes_resolve_ip=false cdn_role=origin cdn_groups=EU
- Origin US
cdn_enabled=true cdn_ip=origin_us.flashponer.com cdn_point_of_entry=origin_eu.flashponer.com cdn_nodes_resolve_ip=false cdn_role=origin cdn_groups=US
- Edge 1 EU
cdn_enabled=true cdn_ip=edge1_eu.flashphoner.com cdn_point_of_entry=origin_eu.flashponer.com cdn_nodes_resolve_ip=false cdn_role=edge cdn_groups=EU
- Edge 1 US
cdn_enabled=true cdn_ip=edge1_us.flashphoner.com cdn_point_of_entry=origin_eu.flashponer.com cdn_nodes_resolve_ip=false cdn_role=edge cdn_groups=US
The bigger the number of viewers is, the more diverse the devices for playback and the channels to these devices are. To provide good broadcast quality to various devices, it will most likely be needed to transcode the video, which can be imposed on special Transcoder servers
Setup example:
- Origin
cdn_enabled=true cdn_ip=origin.flashponer.com cdn_nodes_resolve_ip=false cdn_role=origin cdn_groups=default
- Transcoder EU
cdn_enabled=true cdn_ip=transcoder_eu.flashponer.com cdn_point_of_entry=origin.flashponer.com cdn_nodes_resolve_ip=false cdn_role=transcoder cdn_groups=EU
- Edge 1 EU
cdn_enabled=true cdn_ip=edge1_eu.flashphoner.com cdn_point_of_entry=origin.flashponer.com cdn_nodes_resolve_ip=false cdn_role=edge cdn_groups=EU
As we have found during the test, the number of processor cores is essential for the purposes of transcoding. The most suitable configuration in CPU-optimized configuration line is the most expensive one – 32 vCPU, 64 Gb RAM. At the same time the prices for CPU configurations similar in quantity and with bigger memory in other lines can be significantly higher. Unfortunately, one does not get to save money on transcoders: as the video is encoded frame by frame, there has to be enough memory space for all the images and enough processors for processing all the streams.
During CDN deployment, the simultaneous creation of several servers with the same configuration will come in useful. However, in the case of geographically dispersed CDN same-type Edge and Transcoder servers will need to be hosted in different data centers.
Conclusion
To conclude, we have deployed and tested a small server for low latency WebRTC video streaming on Digital Ocean and have found that a server with minimum configuration is a good fit not only for testing but also for small projects. We have obtained the scaling data depending on the intended number of viewers and have touched upon the subject of CDN deployment, which as such deserves to be discussed in a separate article. To be continued, please stay with us.
References
Flashphoner WebCallServer image in DigitalOcean Marketplace
Load testing method
Web Call Server – WebRTC server