Skip to content

How to quickly copy the DVR archive to a secondary server and increase the simultaneous number of viewers

On this page:

  1. Why use DVR replication?
  2. How DVR replication works.
  3. How to configure DVR replication.

    3.1. DVR replication of all streams.
    3.2. DVR replication of a certain stream.
    3.3. How to specify a separate port for DVR replication.

Replication is a mechanism for copying DVR (Digital Video Recorder) archive from the primary server to secondary ones. You can automatically recover the lost archive segments after a crash or a failure.

Why use DVR replication?

You can use the Flussonic replication mechanism to:

  • Extend the DVR service and raise the simultaneous number of viewers.
  • Quickly start a new DVR server or a DVR server after a crash.
  • Automatically recover a DVR archive after a crash.

90% of the time the primary DVR server is enough to serve all the viewers. The primary server writes the archive to the disk and delivers the segments to the viewers from any point of the timeline in the DVR archive. This way, viewers can watch recorded live streams at different times, with one viewing 24 hours after the live stream and another viewing 72 hours after, each receiving unique content.
In the evening, when people return home from work, the number of viewers increases.
To serve more viewers and deliver archive segments without overloading the primary server:

  1. Connect secondary server.
  2. Replicate the archive from the primary server to the secondary server.
  3. Redirect new viewers to the secondary server.

Based on the viewing statistics on the DVR content, the time between the first and the second request of the same archive segment is 18 hours. Hence, it's cheaper and easier to copy the archive to the secondary server than configuring local cache. This way, viewers can watch the content without interruptions.

By adding a secondary server the service bandwidth and the disk read speed double, allowing to serve twice as many viewers. The main goal of the primary server isn't to overload the replication channel to the secondary server while also distributing content to viewers.

When you need to get a secondary DVR server up and running in a short period of time to deliver archive segments to viewers, use replication. Instead of recording a week's worth of archive from scratch on a secondary server and waiting seven days, you can replicate the archive from the primary server in a few hours and have the secondary server ready. Segments of the archive are time-synchronized, so viewers won't see any difference in the content they receive.

How DVR replication works

Diagram 1. DVR replication process

DVR replication diagram

Primary server:

  1. receives a live stream from the source
  2. records and stores it
  3. broadcasts the live stream and recording segments to viewers

Primary server doesn't know about the secondary server. When the secondary server starts, it does the following:

  1. Connects to the primary server.
  2. Captures the live stream and copies the archive from the primary server. Because of this, the read speed from the primary server disk increases along with the write speed to the secondary server disk.
  3. As the secondary server finishes replicating the archive, it delivers the archive segments to new viewers.

How to configure DVR replication

You can configure replication of all streams or a certain stream from the primary server.

DVR replication of all streams

You can set up DVR replication of all streams in the Flussonic UI or in the configuration file /flussonic/flussonic.conf.

In the Flussonic UI

To turn on the replication of all streams from the primary server to the secondary server in the Flussonic UI, follow these steps:

  1. On the secondary server, in the drop-down menu on the left, open the Config section and go to the DVR tab.
  2. In the Additional section, check the Dvr replicate box. Specify a separate port for replication in the Replication port field if required (see How to specify a separate port for DVR replication).

DVR replicate source

  1. Save the settings by clicking the save icon in the upper-right corner.

After that the secondary server will start replicating the archive.

In the configuration file

To replicate all streams from the primary server to the secondary server, specify the source directive with the replicate option in its DVR settings in the secondary server configuration:

cluster_key abcd;
source primary-server {
  dvr /storage 20d replicate;
}

DVR replication of a certain stream

You can set up DVR replication of a certain stream in the Flussonic UI or in the configuration file /flussonic/flussonic.conf.

In the Flussonic UI

To turn on the replication of a certain stream from the primary server to the secondary server in the Flussonic UI, follow these steps:

  1. On the secondary server, create a new stream and specify the required stream from the primary server as input via M4F or M4S. Save the stream settings by clicking Save.

DVR replicate M4F input

  1. Open the DVR tab in the stream settings and specify the required archive depth. The secondary server will copy the archive from the primary server according to this value.
  2. Check the Dvr replicate box. Specify a separate port for replication in the Replication port field if required (see How to specify a separate port for DVR replication).

DVR replicate in UI

  1. Save the changes by clicking Save.

After that the secondary server will start replicating the archive.

In the configuration file

To configure replication of a certain stream from the primary server to the secondary server, in the configuration file /flussonic/flussonic.conf of the secondary server do the following:

  1. Create a new stream and specify the required stream from the primary server as input via M4F or M4S: input m4f://PRIMARY-SERVER-IP/STREAM_NAME.
  2. In the stream settings, specify the required archive depth. The secondary server will replicate the archive from the primary server, according to this value: dvr /STORAGE_NAME 7d.
  3. In the DVR dvr settings of the stream, add the replicate option. Specify a separate port for replication in the replication_port= parameter if required (see How to specify a separate port for DVR replication).

See the examples of configurations of the primary and secondary servers:

  • Primary server stream configuration:
stream fake {
  input fake://;
  dvr /storage 7d;
}
  • Secondary server stream configuration:
stream repl_example1 {
  input m4f://primary-server-ip/fake;
  dvr /storage 7d replicate;
}

In the example, the primary server connects to the stream source, and the secondary server copies the archive from the primary server as opposed to the cross-replication.

Warning

Don't use the dvr_offline option, which turns off the recording, instead of dvr because the replicate option enables recording automatically.

How to specify a separate port for DVR replication

Note

Replication works with the Flussonic protocol—M4F. Use M4F when transmitting video between Flussonic servers. You can read more about the benefits of the M4F protocol in the M4F overview.

By default, replication uses the port specified when configuring the M4F source. To prevent channel from overloading and your service from failing, you can specify a separate port for replication. You can do that in the Flussonic UI or in the coonfiguraiotn file /flussonic/flussonic.conf.

In the Flussonic UI

  1. If you configure replication for a certain stream, in the stream settings of the secondary server, go to the DVR tab. Check the DVR replicate box and specify the replication port in the Replication port field.

    If you configure replication for all streams, on the secondary server, in the drop-down menu on the left, open Config and click the DVR tab. In the Additional section, check the Dvr replicate box and specify the replication port in the Replication port field.

    Click Save to save the settings.

  2. On the primary server, in the drop-down menu on the left, open the Config section. On the Settings tab, under Listeners section, specify the same HTTP port as in the earlier step by clicking the add icon. Click Save to save the settings.

In the configuration file

  1. In the configuration file of the secondary server, specify the port number in the replication_port parameter next to the replicate option in the stream settings, if you configure replication for a certain stream. If you configure replication for all streams, do the same, but in the source directive:
stream repl_example2 {
  input m4f://primary-server-ip/fake;
  dvr /storage 7d replicate replication_port=8002;
}
  1. In the primary server settings, specify the same port number using the http option:

http 8002

See also: Cross replication for archive restoring.