CDN based on WCS servers can be organized in two ways:
In this section we describe dynamic CDN based on Web Call Server 5.1.
Distributed dynamic content delivery network (CDN) based on WCS 5.1 operates as follows:
Upon startup of the server, a special CDN module starts. The module sends a request to the server specified as the CDN entry point to retrieve from it the list of other servers in the CDN and the list of available streams. If the entry point is not specified or if the specified server is not available, the module waits for a notification from another server in the CDN (for example, if that server was already added to the list of CDN servers on another server, or if it was specified as the entry point). As a result, each active CDN server at any given moment has the up-to-date list of all other CDN servers.
All interaction between nodes of CDN is performed via Websocket.
A server can perform one of two roles
Streams are not distributed by force. An Edge server fetches a specific stream from Origin only upon user request from a browser or a mobile application.
A stream name is unique for every WCS server (and identifies the stream unambiguously), but not for the CDN in a whole. Hence, there are two limitations:
To configure CDN, the following main settings in the flashphoner.properties file are used (see the complete list in the settings file description):
Parameter | Default value | Type | Description |
---|---|---|---|
cdn_enabled | false | Boolean | Enable/disable CDN |
cdn_ip | Empty | String | Server address in CDN |
cdn_nodes_resolve_ip | false | Boolean | Resolve server names to IP addresses |
cdn_point_of_enry | Empty | String | Address of the server, the entry point to CDN for the given server |
cdn_port | 8084 | Int | Port number for CDN |
cdn_role | edge | String | Role of the server in CDN: origin - source of streams for other servers in CDN edge - can receive streams from other servers |
Two servers: Origin (origin.flasphoner.com) and Edge (edge.flasphoner.com)
Origin settings:
cdn_enabled=true cdn_ip=origin.flashponer.com cdn_nodes_resolve_ip=true cdn_role=origin |
Edge settings:
cdn_enabled=true cdn_ip=edge.flashphoner.com cdn_nodes_resolve_ip=true cdn_point_of_entry=origin.flashponer.com cdn_role=edge |
Four servers: Origin1 (origin1.flasphoner.com), Origin2 (origin2.flasphoner.com) and Edge1 (edge1.flasphoner.com), Edge2 (edge2.flasphoner.com)
Origin1 settings:
cdn_enabled=true cdn_ip=origin1.flashponer.com cdn_nodes_resolve_ip=true cdn_role=origin |
Origin2 settings:
cdn_enabled=true cdn_ip=origin2.flashponer.com cdn_point_of_entry=origin1.flashponer.com cdn_nodes_resolve_ip=true cdn_role=origin |
Edge1 settings:
cdn_enabled=true cdn_ip=edge1.flashphoner.com cdn_point_of_entry=origin1.flashponer.com cdn_nodes_resolve_ip=true cdn_role=edge |
Edge2 settings:
cdn_enabled=true cdn_ip=edge2.flashphoner.com cdn_point_of_entry=origin1.flashponer.com cdn_nodes_resolve_ip=true cdn_role=edge |
Obtaining information about the current status of CDN from the WCS command line is performed with these commands:
Command | Description | Example result | |
---|---|---|---|
show cdn-nodes | Displays the list of node servers in CDN: ACTIVE - the server is running, responds to queries and/or sends notifications PASSIVE - the server is stopped or unavailable |
| |
show cdn-routes | Shows the list of active streams in CDN |
|
By default, when server is stopped or unavailable, it will be displayed in CDN nodes list in PASSIVE state until it will be started again or all the CDN will be stopped. The time interval may be set if necessary to remove inactive node from nodes list. This interval should be set in seconds using the following parameter in flashphoner.properties file, for example
cdn_nodes_timeout=60 |
In this case inactive nodes will be removed from CDN nodes list after 60 seconds of inactivity.
In order to avoid excessive transcoding when distributing streams, you need to coordinate codec settings on Origin and Edge servers.
Let's take a look at the following operation flowchart of the CDN intended to distribute a stream from the web camera and the RTMP encoder:
1. Distributing the stream captured from the Chrome browser
1.1. Origin receives the stream H.264+Opus from Chrome.
1.2. Edge fetches from Origin the stream via WebRTС H.264+Opus, there is no transcoding on Origin.
1.3. A spectator fetches the stream from Edge:
1.3.1. via H.264+Opus, no transcoding on Edge;
1.3.2. via H.264+AAC, Opus > AAC transcoding on Edge.
2. Distributing the stream captured from the RTMP encoder
2.1. Origin receives the stream H.264+AAC from the RTMP streamer.
2.2. Edge fetches the stream from Origin via WebRTС H.264+Opus, AAC > Opus transcoding on Origin.
2.3. A spectator fetches the stream from Edge:
2.3.1. via H.264+Opus, no transcoding on Edge;
2.3.2. via H.264+AAC, Opus > AAC transcoding on Edge.
For operation of such CDN, you should configure codecs in the flashphoner.properties file as follows:
on the Origin server
codecs=opus,mpeg4-generic,alaw,ulaw,g729,g722,telephone-event,h264,vp8,flv,mpv # switching transcoding on, to push to Edge audio in Opus codec only disable_rtc_avoid_transcoding_alg=true |
on the Edge server
codecs=opus,mpeg4-generic,alaw,ulaw,g729,g722,telephone-event,h264,vp8,flv,mpv # exclude AAC from cdn to pull from Origin audio in Opus codec only codecs_exclude_cdn=flv,telephone-event,mpeg4-generic |
1. For testing we use:
2. For the test, configure CDN in the minimum configuration: one Origin and one Edge server
Origin settings:
cdn_enabled=true cdn_nodes_resolve_ip=true cdn_ip=origin.flashphoner.com cdn_role=origin |
Edge settings:
cdn_enabled=true cdn_nodes_resolve_ip=true cdn_point_of_entry=origin.flashphoner.com cdn_ip=edge.flashphoner.com cdn_role=edge |
Here origin.flashphoner.com and edge.flashphoner.com - are examples names of the WCS servers.
Restart Origin and Edge servers. Enter the command line interface of the Edge server, authorize and enter this command
show cdn-nodes |
The result of the command is as follows:
> show cdn-nodes Ip State --------------------------- origin.flashphoner.com ACTIVE |
3. Open the Two Way Streaming web application on the Origin server. Click the Connect button and specify the name of the broadcast stream testCDN:
4. Click the Publish button. The stream is published from the web camera:
5. Open the Player web application on the Edge server. Specify the name of the stream broadcast to the Origin server, testCDN:
6. Click the Start button. Playing of the testCDN stream starts.
7. In the command line interface of the Edge server enter the command
show cdn-routes |
The result of executing the command is:
> show cdn-routes Route Stream -------------------------------- 0-origin.flashphoner.com-0 testCDN |
8. Click the Stop button on the stream publishing page. Publishing stops:
On the play page of the Edge server playing of the stream also stops and the message "Stopped by publisher stop" displays.
1) Changing codec settings on the Edge server can lead to increased load on the server as a result of enabled transcoding.
Symptoms: when a large number of streams are broadcast, the load on the CPU of the Edge server increases
Solution: configure codec settings on Origin and Edge servers so to reduce excessive transcoding.
For instance, if the codec setting on the Origin server specifies the following set of codecs:
codecs=opus,mpeg4-generic,alaw,ulaw,g729,g722,telephone-event,h264,vp8 |
and the setting on the Edge server is
codecs=opus,speex16,mpeg4-generic,g729,g722,h264,vp8 |
then, when a stream is broadcast through the Edge server, audio transcoding from Speex16 or AAC is activated. With a large number of streams, the load to the CPU of the server can greatly increase.