Wowza Media Server is a Video Stream Server used by popular CDN providers to provide video content across the internet. It has come with a large variety of features and several streaming options. And one of the attractive feature provided by wowza is that, it allows clustering like feature so that multiple servers can be configured to provide a video stream to the clients. In such a setup one of the server will act as a loadbalancing server and the others will act as the loadbalancing edge/client servres. If a client requests a video stream then a load balancer server redirect it to the least loaded wowza server. This loadbalancing feature is usually used while publishing live streams becuase the number of concurrent connections to the server providing live stream will be high and a load balancing setup can easily manage it. Here we will discuss the load balancing setup for a live stream proess.

To employ loadbalancing setup in live streaming first we have to setup live streaming repeater configuration available with wowza. This is because the live stream will be actually published to only one server and we need to duplicate among a no of stream servers as our need. So there will be live repeater origin server and several live repeater edge servers. When the player will request the contentfrom an edge server and the edge server will maintain a single connection per-unique stream to the origin. Origin and edge configuration is an application level configuration. A single Wowza Server instance can be configured as an origin for one application and an edge for another.

1) Configuring liverepeater-origin server
  • Create a folder named [install-dir]/applications/liverepeater.
  • Create a folder named [install-dir]/conf/liverepeater and copy the file [install-dir]/conf/Application.xml into this new folder.
  • Edit the newly copied Application.xml file and make the following changes:

a) Change the Streams/StreamType to liverepeater-origin

b. Change the LiveStreamPacketizers to: cupertinostreamingpacketizer,smoothstreamingpacketizer

2)Configuring edge server

Follow these steps to configure each of the edge servers

  • Create a folder named [install-dir]/applications/liverepeater.
  • Create a folder named [install-dir]/conf/liverepeater and copy the file [install-dir]/conf/Application.xml into this new folder.
  • Edit the newly copied Application.xml file and make the following changes.

a)Change the Streams/StreamType to liverepeater-edge (you can use the liverepeater-edge-lowlatency stream type if low latency is important, this will add extra load to the server).

b)Change the LiveStreamPacketizers to: cupertinostreamingrepeater,smoothstreamingrepeater

c)Uncomment the Repeater/OriginURL section and set OriginURL to rtmp URL of the origin server. For example if the origin server uses the domain name      origin.mycompany.com, this value should be set to:


<Repeater>

         <OriginURL>rtmp://origin.mycompany.com</OriginURL>

         <QueryString></QueryString>

</Repeater>

Note: Let us assume origin.mycompany.com is the origin server here

3)Configring the Loadbalancer server

  • First Download the loadbalancing module the from the following link of wowza forums. Unzip the downloaded file

http://www.wowzamedia.com/forums/showthread.php?t=4637

  • Copy the file lib/wms-plugin-loadbalancer.jar from this zip archive to the [install-dir]/lib/ folder of Wowza Media Server 2
  • Copy the file conf/crossdomain.xml from this zip archive to the [install-dir]/conf/ folder of Wowza Media Server 2.
  • Edit [install-dir]/conf/Server.xml and make the following changes:

Add the following ServerListener entry to the <ServerListeners> list:

    <ServerListener>
           	  <BaseClass>com.wowza.wms.plugin.loadbalancer.ServerListenerLoadBalancerListener</BaseClass>
    </ServerListener>

Add the following properties to the <properties> section of the bottom of the server.xml file

      <Property>
               <Name>loadBalancerListenerKey</Name>
	      <Value>023D4FB4IS83</Value>
      </Property>
      <Property>
	      <Name>loadBalancerListenerIpAddress</Name>
	      <Value>*</Value>
      </Property>
      <Property>
	     <Name>loadBalancerListenerPort</Name>
	     <Value>1934</Value>
	     <Type>Integer</Type>
      </Property>
      <Property>
	      <Name>loadBalancerListenerRedirectorClass</Name>
	      <Value>com.wowza.wms.plugin.loadbalancer.LoadBalancerRedirectorConcurrentConnects</Value>
      </Property>
      <Property>
	      <Name>loadBalancerListenerMessageTimeout</Name>
	      <Value>5000</Value>
	      <Type>Integer</Type>
      </Property>
  • Edit [install-dir]/conf/VHost.xml and add the following HostPort/HTTPProvider XML snippet just before the HTTPProvider definition for com.wowza.wms.http.HTTPServerVersion:
      <HTTPProvider>
                   <BaseClass>com.wowza.wms.plugin.loadbalancer.HTTPLoadBalancerRedirector</BaseClass>
	           <RequestFilters>*loadbalancer</RequestFilters>
	           <AuthenticationMethod>none</AuthenticationMethod>
	           <Properties>
                              <Property>
		          	  <Name>enableServerInfoXML</Name>
                   		  <Value>true</Value>
		                  <Type>Boolean</Type>
		           </Property>
	         </Properties>
     </HTTPProvider>

4)To setup an edge servers in load balancing

Do the first two steps as done for the load balacer server

  • Edit [install-dir]/conf/Server.xml and make the following changes:

Add the following ServerListener entry to the <ServerListeners> list:


     <ServerListener>
	           <BaseClass>com.wowza.wms.plugin.loadbalancer.ServerListenerLoadBalancerSender</BaseClass>
     </ServerListener>

Add the following properties to the <Properties> section at the bottom of Server.xml:


   <Property>
	    <Name>loadBalancerSenderTargetPath</Name>
	    <Value>${com.wowza.wms.AppHome}/conf/loadbalancertargets.txt</Value>
   </Property>
   <Property>
	    <Name>loadBalancerSenderRedirectAddress</Name>
	    <Value>[redirect-address]</Value>
   </Property>
   <Property>
            <Name>loadBalancerSenderMonitorClass</Name>
	    <Value>com.wowza.wms.plugin.loadbalancer.LoadBalancerMonitorDefault</Value>
   </Property>
   <Property>
	    <Name>loadBalancerSenderMessageInterval</Name>
	    <Value>2500</Value>
	    <Type>Integer</Type>
   </Property>

Where [redirect-address] is the external ip address or domain name of this machine. This address will be used when redirecting to this edge server. When using this system on EC2 you can set the [redirect-address] to   ${com.wowza.amazonaws.ec2.AWSEC2_METADATA_PUBLIC_IPV4} and upon server startup it will use the public ip address of the server for this value.

  • Create the file [install-dir]/conf/loadbalancertargets.txt using a text editor and enter the following two lines (the first line is a comment):

# [load-balancer-ip-address],[load-balancer-port],[encryption-key]

[load-balancer-ip-address],1934,023D4FB4IS83


Where [load-balancer-ip-address] is the ip address or domain name of the load balancer.

This configurations uses UDP port 1934 for communication between the edge servers and the load balancer. Be sure this port is open on your firewall. All communication between the edge server and the load balancer is encrypted and signed. The encryption key is set on the load balancer server using the loadBalancerListenerKey property and in the loadbalancertargets.txt file on the edge servers. These keys must match. An edge server can communicate with multiple load balancers by adding additional lines to the loadbalancertargets.txt file.

You can now startup the load balancer and multiple edge servers. If functioning properly, the edge servers will update the load balancer every 2.5 seconds with status and load information. You can get information from the load balancer in regards to which edge servers are currently registered and their status by opening a web browser and entering the following url:

 http://[load-balancer-ip-address]:1935/loadbalancer?serverInfoXML

5)Now Configure a redirect application to redirect the connection requests to the least loaded server.
  • Create the folder [install-dir]/applications/redirect.
  • Create the folder [install-dir]/conf/redirect and copy the file [install-dir]/conf/Application.xml into this new folder.
  • Create the folder [install-dir]/conf/redirect and copy the file [install-dir]/conf/Application.xml into this new folder.
      <Module>
	    <Name>ModuleLoadBalancerRedirector</Name>
	    <Description>ModuleLoadBalancerRedirector</Description>
            <Class>com.wowza.wms.plugin.loadbalancer.ModuleLoadBalancerRedirector</Class>
      </Module>
  • Add the following properties the properties section at the bottom of the Application.xml file:
   <Property>
             <Name>redirectAppName</Name><code>
             <Value>[application-name]</Value>
    </Property>
    <!--
    <Property>
	     <Name>redirectPort</Name>
	     <Value>[redirect-port]</Value>
    </Property>
    -->
    <!--
    <Property>
	     <Name>redirectScheme</Name>
              <Value>rtmp</Value>
    </Property>
    -->
    <Property>
	     <Name>redirectOnConnect</Name>
	     <Value>true</Value>
	     <Type>Boolean</Type>
    </Property>

Where [application-name] is the name of the application you wish to redirect to on the edge server and [redirect-port] is the port to redirect to (such as port 1935 or port 80). The redirectPort and redirectScheme are commented out so that the system will use the same scheme and port used to connect to the load balancer to connect to the edge server. This will work better when using any type of protocol (rtmp to rtmpt) or port rollover scheme.

 

VN:F [1.9.6_1107]
Rating: 7.3/10 (28 votes cast)
VN:F [1.9.6_1107]
Rating: +10 (from 12 votes)
Load balancing in Wowza Media Server, 7.3 out of 10 based on 28 ratings
Share and Enjoy:
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • Live
  • StumbleUpon
  • Twitter
  • Yahoo! Buzz
  • Reddit
  • Technorati