November 13, 2013

How to make robust streaming with Nimble Streamer

As we mentioned in the previous post, building robust content delivery network means that the content must be delivered regardless of availability of all servers. There we've reviewed the techniques available for anyone to build a simple re-streaming infrastructure with content origin, streaming edges and DNS failover.

Let's build this delivery network using DigitalOcean hosting and Nimble Streamer. We've already used this stack for quick start of VOD streaming, so let's continue using these two for building our first CDN prototype. You can use any other hosting provider best fit for you, like Amazon or Rackspace.



UPDATE
WMSPanel team released the article describing the recommended approach to load balancing for HTTP-based protocols like HLS, DASH, Icecast etc. Please use the technique described there to build your own balancing solution rather than approach shown below.
The DNS failover approach used below is considered obsolete. However, Nimble Steamer installation and the re-streaming setup are correct and may be used for setting up your environment.




OK, so we have a content origin which accepts requests.


We need to make it robust and scalable. The DNS failover technique will be used for that. We'll make a set of re-streaming caching edge servers to provide failover and to allow easily adding new edges in this farm.
Building robust and scalable re-streaming infrastructure.
A few assumptions are applied to current how-to:
  1. We have an origin server properly set up and running. This might be Wowza Media Server, Microsoft IIS, Nginx or any other.
  2. This origin server is available at origin.ultimatemediastreaming.com and it's streaming live video on port 1935 via HLS protocol.
  3. We use ultimatemediastreaming.com domain but you will use any other name for your case.
We will need the following 2 edge servers:
  • Nimble edge 1
  • Nimble edge 2
Let's go step-by-step.

1. Create edge servers


We'll use DigitalOcean hosting provider. You can use this how-to in order to have step-by-step instruction on creating virtual servers there.

So we've got 2 servers as shown below.


Now we need to set up DNS.

2. Set up DNS failover


We need to set up "live.ultimatemediastreaming.com" domain to point to both servers. Go to DNS section and click on magnifying glass icon.


Now click on Add record select A record type, enter live.ultimatemediastreaming.com and 162.243.88.159 - this is the IP address for nimble-edge-1. Then click Create.


Now create the same type of record for 162.243.88.131 - this is the IP for nimble-edge-2.


OK, we've got DNS properly set up. You can refer to this post for details about how DNS failover works.

Now it's time to set up Nimble Streamer.

3. Install Nimble Streamer


Log into nimble-edge-1. Just run a terminal and enter:
ssh root@162.243.88.159
You'll then be asked for a password which you will also enter.

Then we need to say Ubuntu about the repository where it will install Nimble Streamer from. Run this:
echo "deb http://nimblestreamer.com/ubuntu precise/" >> /etc/apt/sources.list

And update repository by running:
apt-get update
Now install Nimble Streamer:
apt-get install nimble
The system will ask for confirmations several times during the installation process. Each time, just press "y" and then "Enter".

To control Nimble Streamer we'll use WMSPanel cloud control panel.

Go to Sign up page and enter your email.

Check the email you've used during installation. You'll get a login and a password there. Go to Log in page and enter your credentials.


Let's add nimble-edge-1 server into the panel. Go back to the terminal window. Run this command:
/usr/bin/nimble_regutil
and enter WMSPanel credentials from the email you've used for logging in.

The server has been added into control panel, you'll just need to restart it:
service nimble restart
Go back to WMSPanel and open Servers page. You will see the server added there.


Now set up nimble-edge-2 the same way we've set up nimble-edge-1. Both servers are shown in the panel now.


4. Set up streaming routes


Now we need to set up the routes for taking content from origin via edge to the client. Go to Control / Edit Nimble Routes menu.


Click on Add re-streaming route.


Let's set up the re-streaming routes to set all edges for listening at http://live.ultimatemediastreaming.com:8081/ address and re-stream the video from origin address http://origin.ultimatemeadiastreaming.com:1935/. To apply it to both edge servers, check their names in the list and lick OK.

Hint: Nimble Streamer may act as an origin server for both VOD streaming from MP4 and live streaming from RTMP and MPEG-TS.


Now you see a new route in the list.


All servers assigned to this route will get this route automatically.

5. Start streaming


Well done! Now you've got 2 caching re-streaming edges balanced via DNS failover. To improve robustness and increase total throughput, you can just add new server using step 1 and add new DNS record using step 2. As already mentioned, it can be done with any other hosting provider like Amazon or Rackspace. WMSPanel is not affiliated with neither of the mentioned companies.

Our live stream can be accessible via this URL as example: http://live.ultimatemediastreaming.com:8081/live/stream/playlist.m3u8
It will work regardless of the number of edges behind the designated domain name.

BTW, this technique is used for our Nimble Streamer demo video page. The video is processed from 3 servers located in 3 different geographical locations.

You can learn more about Nimble Streamer features, decide how they can be useful for your business and contact us if you want to make your own streaming infrastructure.

You can also read "The Paranoid’s Guide to Internet Video Streaming" by Thomas Gires to see real-life example of using pay-per-view feature set along with Nimble Streamer as light-weight edge for HLS re-streaming.


No comments:

Post a Comment