The well-known cloud hosting DigitalOcean has recently acquired its own store with ready-made images, from which you can quickly deploy any application server. Just like AWS, only DO, for those who already use the services of this provider. Let's see how, having a DO account, deploy a simple server for $ 10 per month for streaming WebRTC based on Flashphoner WebCallServer, and how such a server can be useful.
Deployment
We enter the account on DO, follow the link to the Flashphoner WebCallServer image and click the "Create Flashphoner Web Call Server Droplet" button
We select the characteristics of the north and the tariff plan. By default, DO will offer us something from the middle segment, but we are interested in the minimum cost
Choose the region where the data center is located, for example, Frankfurt
Choose an authentication method, for example, a one-time password
We indicate the number of servers (while we are interested in one server) and give our server a name. This name will be written, including, in / etc / hostname
Click "Create droplet"
After creation, the server will automatically start. You can connect to it via SSH and, if a one-time password was selected as the authentication method, change the password. A brief description of Flashphoner WebCallServer with documentation links will be displayed in the console
"This is a test. Can I see you?"
Flashphoner WebCallServer starts up ready to go, a 30-day trial license is activated automatically. To test all the basic functions there is a web interface, we restrict ourselves to checking the publication and playback of WebRTC stream.
Open the browser page https: // droplet_ip: 8444 / admin / . By default, a self-signed certificate is supplied with the server, so you will have to confirm the security exception. In the future, you can replace the certificates with your own. Enter username and password (default demo )
Select the Two-Way Streaming example in the sidebar, click the "Connect" button, then "Publish". To play the stream, click "Play"
For a handful of dollars
What is a server capable of for $ 10 per month capable of being a hardware platform for WebRTC streaming? Let's see what the DigitalOcean processor offers us
lscpu
and from memory
free -h
Checking the server with load tests, we see that the server may not be so small.
For example, weβll publish one stream instance and see how many subscribers can lose this stream at the same time, occupying no more than 90% of the processor:
Resolution | Bitrate, Kbps | Number of publications | Number of subscribers |
---|---|---|---|
360p | 1300 | one | 70 |
480p | 1800 | one | 70 |
720p | 3000 | one | fifty |
With several simultaneous publications, the maximum number of processed streams remains at the same level: if you publish 7 streams, up to 10 viewers can subscribe to each.
Let's say we need to transcode the stream on the server in order to reduce the resolution or align the FPS. For this case, check the maximum number of publications:
Resolution | Bitrate, Kbps | Number of threads |
---|---|---|
360p | 1300 | 5 |
480p | 1800 | 3 |
720p | 3000 | 2 |
Thus, a minimum cost server on DO with parameters of 1 CPU core, 2 Gb RAM, 2 TB of traffic per month is suitable not only for testing WebRTC streaming, but also for use in small projects. For example, you can:
- distribute via WebRTC a stream from an IP camera for the simplest corporate video surveillance;
- organize a webinar for employees of a small company
- raise your Internet radio (audio stream requires less CPU resources)
In addition, this server can be considered as a reference platform for scaling calculations, which we will continue to do.
"I deserve more!"
The rules, in general, are very simple: there are not many cores, and so are the memory. Depending on the planned number of subscribers, recommendations from the set of configurations offered by DO will be as follows:
Number of subscribers | vCPUs | RAM, Gb | Traffic, TB | Usage example |
---|---|---|---|---|
up to 200 | 4 | 8 | 5 | Video surveillance system |
up to 500 | 8 | sixteen | 6 | Webinars |
up to 1000 | sixteen | 64 | nine | Video conference |
up to 2000 | twenty | 96 | 10 | Streaming HD video |
If you plan to grow further, you will have to deploy a CDN at the rate of 1 Edge server for 2000 subscribers. Suppose we need to distribute HD video, the planned number of viewers is 10,000. In this case, we need 2 Origin servers for publishing and 5 Edge servers for viewing.
Setting 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 cdn_point_of_entry=origin1.flashponer.com cdn_nodes_resolve_ip=false cdn_role=origin
- Edge 1 - Edge 5 (only the server address in the
cdn_ip
parameter iscdn_ip
)
cdn_enabled=true cdn_ip=edge1.flashphoner.com cdn_point_of_entry=origin1.flashponer.com cdn_nodes_resolve_ip=false cdn_role=edge
A CDN can also be useful if subscribers are geographically distributed, for example, our potential viewers live in Europe and America.
Setting 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 more viewers, the greater the variety of playback devices and channels to these devices. To ensure the quality of broadcasting to various devices, most likely, video transcoding will be required, which can be assigned to special CDN Transcoder servers.
Setting 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
For transcoding, as we found out during the test, the number of processor cores is important. From the CPU-optimized configuration line, the most expensive 32 vCPU, 64 Gb RAM is most suitable. At the same time, in other lines, configurations with a large amount of memory close in the number of CPUs can be significantly more expensive. Unfortunately, saving on transcoders will not work: since the video is encoded frame by frame, there should be enough memory for all pictures, and processors for processing all streams.
When deploying a CDN, itβs useful to create multiple servers of the same configuration at the same time. However, for geographically distributed CDNs, the same type of Edge and Transcoder servers will need to be located in different data centers.
Conclusion
So, we deployed and tested a small server for streaming WebRTC video with low latency on DigitalOcean, made sure that the server in the minimum configuration is suitable not only for testing, but also for use in small projects, we received data for scaling depending on the expected number of viewers, and touched on the topic of CDN deployment, which in itself deserves a separate article. Stay with us, to be continued ...
References
Flashphoner WebCallServer at DigitalOcean Marketplace - A pre -built image of Web Call Server at DigitalOcean.
Low latency WebRTC streaming CDN is a Web Call Server-based content delivery network.