Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 5 Next »

CDN based on WCS servers can be organized in two ways:

  1. Static CDN with pre-configured nodes. Changing CDN configuration requires restarting the server(s), because in this scheme the server(s) are the source of streams in the network. Such CDN 1.0 can be organized based on the load balancing function.
  2. Dynamic CDN with dynamically changing nodes. To include/exclude a node to/from such CDN, restarting of this node only is required.

In this section we describe dynamic CDN based on Web Call Server 5.1.

Overview

Dynamic CDN operation principle

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.

Server roles in CDN

A server can perform one of two roles

  1. Origin: works as a source of streams for other servers in CDN. Can distribute both streams published on it and streams fetched from other servers.
  2. Edge: can fetch streams from Origin servers, but do not distribute its own (local) streams to other servers.

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.

Operation flowchart

  1. The browser connects to the Origin server via the Websocket protocol and sends the publish command.
  2. The browser captures the microphone and the camera and sends the WebRTC stream to the server.
  3. The second browser establishes a connection to the Edge3 server via Websocket and sends the play command.
  4. The Edge3 server requests the stream from the Origin server.
  5. The Edge3 server receives the WebRTC stream.
  6. The second browser receives the WebRTC stream and plays this stream on the page.

Stream identification principles in CDN

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:

  1. If a stream is published on the server, and there is another stream with the same name on some other Origin server, the local (non-CDN) stream will be played on that server.
  2. When a CDN stream is played on the server, a stream with the same name cannot be published on that server. The same name can be used for publishing only when the playback stops and the pull agent is deleted after the activity checking timeout expires (by default it is 1 minute).

Configuration

Parameters of the settings file

To configure CDN, the following main settings in the flashphoner.properties files 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

Configuration examples

Minimum configuration example

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

Two Origin servers configuration example

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

Using CLI

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

IIp                       State        
---------------------------------
edge1.flashphoner.com    ACTIVE   
edge2.flashphoner.com    ACTIVE   
origin2.flashphoner.com  PASSIVE

show cdn-routes

Shows the list of active streams in CDN

Route                       Stream     
------------------------------------
1-origin2.flashphoner.com-2 stream1
0-origin2.flashphoner.com-0 stream2
2-origin1.flashphoner.com-1 stream1

Coordination of codecs on Origin and Edge servers

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

Quick manual on testing

1. For testing we use:

  • two WCS servers;
  • the Two Way Streaming web application to publish the stream;
  • the Player web application to play the stream.

Configuring WCS

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

Running a broadcast form a web camera to the Origin server

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:

Playing the stream on the Edge server

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

Stopping broadcasting from the web camera to the Origin server

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.

Known issues

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.

  • No labels