Name Last modified Size Description
Parent Directory -
AC_RunActiveContent.js 02-Mar-2010 01:49 8.1K
README.html 02-Mar-2010 09:47 13K
httpgetredirect.html 02-Mar-2010 01:49 2.0K
httpgetredirect.swf 02-Mar-2010 01:49 31K
redirect.html 02-Mar-2010 01:49 2.0K
redirect.swf 02-Mar-2010 01:49 31K
This package provides system for load balancing between multiple Wowza Media Server 2 servers. It leverages the IServerNotify (ServerListener) interface in Wowza Media Server 2. Each edge server is configured to use the ServerListenerLoadBalancerSender ServerListener class. We will call these servers the "edge" servers. Edge servers will periodically (about every 2.5 seconds) send load and status information over UDP to a single (or multiple) Wowza Media Server 2 servers running the ServerListenerLoadBalancerListener ServerListener. We will call this server the "load balancer". The load balancer will keep track of the load and availablility of each of the edge servers to which it is communicating.
When a Flash client wishes to communicate with one of the edge servers, it will first make a request to the load balancer to get the address of the least loaded edge server. The Flash client will then connect directly to this edge server. There are currently two ways for a Flash client to obtain the address of the least loaded edge server. The first method is to make a NetConnection.connect() request to an application on the load balancer that is running the ModuleLoadBalancerRedirector module. The ModuleLoadBalancerRedirector module rejects this connection request with a info.code of "NetConnection.Connect.Rejected". The redirect url will be contained in the info.ex.redirect field. The second method is to make an HTTP request to the load balancer from Flash using the URLLoader class. The load balancer will return the redirect host name or ip address in the response to this request. This package includes Flash examples of both of these methods.
The load balancing mechanism is dynamic. Each time a new edge server is started or stopped it will communicate with the load balancer to send its current status. This makes it very easy to add and remove servers from the pool of availabe edge servers simply by starting or stopping an edge server. There is also a Java and JMX API for temporarily removing an edge server from the pool. All of this is discussed below.
<ServerListener>
<BaseClass>com.wowza.wms.plugin.loadbalancer.ServerListenerLoadBalancerListener</BaseClass>
</ServerListener>
<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>
<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>
<ServerListener>
<BaseClass>com.wowza.wms.plugin.loadbalancer.ServerListenerLoadBalancerSender</BaseClass>
</ServerListener>
<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>
# [load-balancer-ip-address],[load-balancer-port],[encryption-key]
[load-balancer-ip-address],1934,023D4FB4IS83
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
Where [load-balancer-ip-address] is the ip address or domain name of the load balancer. It will return an XML document contains detailed information on each of the edge servers. Once you have your load balancing server up and running and in a production environment, you may wish to turn off this query interface. You can do this by setting the HTTPProvider/Properties/Property enableServerInfoXML in [install-dir]/conf/VHost.xml to false.
One of the methods to get the least loaded server from the load balancer is to make a request to the load balancer over http. The url for this request is:
http://[load-balancer-ip-address]:1935/loadbalancer
Where [load-balancer-ip-address] is the ip address or domain name of the load balancer. This request will return the ip address of the least loaded server in the form "redirect=[ip-address]". The Flash example client/httpgetredirect.fla includes the ActionScript 3.0 code needed to make this request and parse the response. You can also test the load balancer by entering this url into a web browser.
You can also get the least loaded server by configuring an application on the load balancer that uses the ModuleLoadBalancerRedirector module. To setup an application that uses this module follow these steps:
<Module>
<Name>ModuleLoadBalancerRedirector</Name>
<Description>ModuleLoadBalancerRedirector</Description>
<Class>com.wowza.wms.plugin.loadbalancer.ModuleLoadBalancerRedirector</Class>
</Module>
<Property>
<Name>redirectAppName</Name>
<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>
The Flash example client/redirect.fla includes the ActionScript 3.0 code to handle an RTMP redirect.
NOTE: You can setup multiple load balancer servers for failover or to handle the connection load by starting additional load balancer servers and adding additional target configuration lines to the loadbalancertargets.txt file on the edge servers.
NOTE: This system uses the global unique identifier (GUID) that is stored in the [install-dir]/conf/Server.guid file to uniquely identify a server. If Wowza Media Server 2 is installed on and edge server by copying the installation directory from one to server to another be sure to remove the [install-dir]/conf/Server.guid file from the new install so that the first time is is launched a new identifier will be generated for this server.
NOTE: Both the ServerListenerLoadBalancerListener and ServerListenerLoadBalancerSender classes expose attributes and operations through the JMX/JConsole interface that enable monitoring and administration of the system. The ServerListenerLoadBalancerSender class (edge server) exposes two operations pause and unpause that can be used to temporarily remove an edge server from the load balancer pool. When in the paused state, the load balancer will not send any new connections to the paused edge server.