HOW TO SETUP WOWZA LOADBALANCING.
Wowza server used for video and audio streaming with wowza loadbalancing you can add more servers as called edge servers and one server used as origin server which we use to connect using flash media encoder and start streaming. When users starts watch your stream wowza loadbalancing starts sharing all of your edge server and start sending viewers on edge servers in rotation wise.
Lets setup wowza loadbalancing on multiple edge servers.
To setup a load balancer "listener" known as origin server.
We setup live application on origin and in that application.xml we put liverepeater-origin as stream type.
- Install Wowza Media Server 2 Preview 7 (or greater).
- 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 at the bottom of Server.xml:<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>
To setup a load balancer "sender" on an "edge"server
We setup liverepater application on edge and in that application.xml we put liverepeater-edge as stream type.
- Install Wowza Media Server 2 Preview 7 (or greater).
- Copy the file lib/wms-plugin-loadbalancer.jar from this zip archive to the [install-dir]/lib/ 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.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>edge server ip put here</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>
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/PropertyenableServerInfoXML in [install-dir]/conf/VHost.xml to false.
Get least loaded server using http
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.
Get least loaded server using Netconnection redirect
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:
- 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.
- Edit the newly copied Application.xml file and add the following module entry as the last entry in the modules list:
<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> <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). TheredirectPort 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.