How to setup WSO2 Load Balancer
Load balancing is a key concern in a Platform-as-a-Service (PaaS) or a middleware platform deployed on the Cloud. An Elastic Load Balancer (ELB), in addition to carrying out its functionality in load balancing, is also responsible for monitoring the load & starting up new worker nodes or terminating existing worker nodes, depending on the load. An ideal use case of the Load Balancer is WSO2 StratosLive, where the service instances are fronted with the load balancers and the system scales automatically as the service gets more web service calls. Here in this article we will see how to configure WSO2 Load Balancer Balance to use with Application server cluster
You can download WSO2 Application server from here http://wso2.com/products/application-server/
You can download WSO2 Load Balancer from here https://wso2.org/projects/load-balancer
1.Configure Application Server Cluster
Edit mgt-transports.xml file as follows
Uncomment the HTTP proxy port in this file. The HTTP proxy port has to be set to port 80.
Edit carbon.xml In this file, we have to specify the Host of the App Server
Edit axis2.xml
In the axis2.xml file, you have to enable the clustering.
Keep rest of this xml file as it is.
2.Configure Load Balancer
Configuring the Load Balancer Cluster
locate the transportReceiver entries for the HTTP & HTTPS ports and change them to port 80 & 443 respectively. The relevant XML segments are shown below.
Edit loadbalancer.xml to map the HTTP host to the clustering domain.Add following segment to services section
Please note that appserver.cloud-test.wso2.com is mapped to 127.0.0.1 in my machine by changing /etc/hosts entries.Also change carbon.xml file located in appserver repository/conf by adding following entry.
Now you have to up and run load balancer product first then run appserver product. You will see following message in loadbalancer log when appserver joins to the load balance cluster.
[2012-02-23 17:34:12,048] INFO - RpcMembershipRequestHandler Received JOIN message from 10.200.2.85:4100(wso2.as.domain)
[2012-02-23 17:34:12,052] INFO - MembershipManager Application member 10.200.2.85:4100(wso2.as.domain) joined group wso2.as.domain
[2012-02-23 17:34:23,062] INFO - DefaultGroupManagementAgent Application member Host:10.200.2.85, Port: 4100, HTTP:9763, HTTPS:9443, ACTIVE:true joined application cluster
Now you can invoke Application server by typing https://appserver.cloud-test.wso2.com:443/carbon/ URL in browser. So you will see the logs related to the requested page in loadbalancer logs.
To remove autoscale you have to remove autoscaler.xml file from wso2lb-1.0.2/repository/deployment/server/synapse-configs/default/tasks folder. Also remove autoscalein and autoscaleout configurations from main.sequence(from main.xml file located in wso2lb-1.0.2/repository/deployment/server/synapse-configs/default/sequences).
Load balancing is a key concern in a Platform-as-a-Service (PaaS) or a middleware platform deployed on the Cloud. An Elastic Load Balancer (ELB), in addition to carrying out its functionality in load balancing, is also responsible for monitoring the load & starting up new worker nodes or terminating existing worker nodes, depending on the load. An ideal use case of the Load Balancer is WSO2 StratosLive, where the service instances are fronted with the load balancers and the system scales automatically as the service gets more web service calls. Here in this article we will see how to configure WSO2 Load Balancer Balance to use with Application server cluster
You can download WSO2 Application server from here http://wso2.com/products/application-server/
You can download WSO2 Load Balancer from here https://wso2.org/projects/load-balancer
1.Configure Application Server Cluster
Edit mgt-transports.xml file as follows
Uncomment the HTTP proxy port in this file. The HTTP proxy port has to be set to port 80.
- <transport name="http" class="org.wso2.carbon.server.transports.http.HttpTransport">
- <parameter name="protocol">HTTP_11_NIO</parameter>
- <parameter name="port">${Ports.ServletTransports.HTTP}</parameter>
- <parameter name="proxyPort">80</parameter>
- <parameter name="maxHttpHeaderSize">8192</parameter>
- <parameter name="acceptorThreadCount">2</parameter>
- <parameter name="maxThreads">250</parameter>
- <parameter name="minSpareThreads">50</parameter>
- <parameter name="disableUploadTimeout">false</parameter>
- <parameter name="connectionUploadTimeout">120000</parameter>
- <parameter name="maxKeepAliveRequests">200</parameter>
- <parameter name="acceptCount">200</parameter>
- <parameter name="server">WSO2 Carbon Server</parameter>
- <parameter name="compression">on</parameter>
- <parameter name="compressionMinSize">2048</parameter>
- <parameter name="noCompressionUserAgents">gozilla, traviata</parameter>
- <parameter name="compressableMimeType">
- text/html,text/javascript,application/x-javascript,application/javascript,
application/xml,text/css,application/xslt+xml,text/xsl,image/gif,image/jpg,image/jpeg - </parameter>
- </transport>
- <transport name="https" class="org.wso2.carbon.server.transports.http.HttpTransport">
- <parameter name="protocol">HTTPS_11_NIO</parameter>
- <parameter name="port">${Ports.ServletTransports.HTTPS}</parameter>
- <parameter name="proxyPort">443</parameter>
- <parameter name="sslProtocol">TLS</parameter>
- <parameter name="maxHttpHeaderSize">8192</parameter>
- <parameter name="acceptorThreadCount">2</parameter>
- <parameter name="maxThreads">250</parameter>
- <parameter name="minSpareThreads">50</parameter>
- <parameter name="enableLookups">false</parameter>
- <parameter name="disableUploadTimeout">false</parameter>
- <parameter name="connectionUploadTimeout">120000</parameter>
- <parameter name="maxKeepAliveRequests">200</parameter>
- <parameter name="acceptCount">200</parameter>
- <parameter name="server">WSO2 Carbon Server</parameter>
- <parameter name="clientAuth">false</parameter>
- <parameter name="compression">on</parameter>
- <parameter name="compressionMinSize">2048</parameter>
- <parameter name="noCompressionUserAgents">gozilla, traviata</parameter>
- <parameter name="compressableMimeType">
- text/html,text/javascript,application/x-javascript,application/javascript,
application/xml,text/css,application/xslt+xml,text/xsl,image/gif,image/jpg,image/jpeg - </parameter>
- <parameter name="keystoreFile">
- ${carbon.home}/repository/resources/security/wso2carbon.jks
- </parameter>
- <parameter name="keystorePass">wso2carbon</parameter>
- </transport>
Edit carbon.xml In this file, we have to specify the Host of the App Server
<HostName>appserver.cloud-test.wso2.com</HostName>
Edit axis2.xml
In the axis2.xml file, you have to enable the clustering.
- <clustering class="org.apache.axis2.clustering.tribes.TribesClusteringAgent" enable="true">
- <parameter name="AvoidInitiation">true</parameter>
- <parameter name="membershipScheme">wka</parameter>
- <parameter name="domain">wso2.as.domain</parameter>
- <parameter name="synchronizeAll">true</parameter>
- <parameter name="maxRetries">10</parameter>
- <parameter name="mcastAddress">228.0.0.4</parameter>
- <parameter name="mcastPort">45564</parameter>
- <parameter name="mcastFrequency">500</parameter>
- <parameter name="memberDropTime">3000</parameter>
- <parameter name="localMemberPort">4100</parameter>
- <parameter name="preserveMessageOrder">true</parameter>
- <parameter name="atmostOnceMessageSemantics">true</parameter>
- <parameter name="properties">
- <property name="backendServerURL" value="https://${hostName}:${httpsPort}/services/"/>
- <property name="mgtConsoleURL" value="https://${hostName}:${httpsPort}/"/>
- </parameter>
- <members>
- <member>
- <hostName>appserver.cloud-test.wso2.com</hostName>
- <port>4000</port>
- </member>
- </members>
Keep rest of this xml file as it is.
2.Configure Load Balancer
Configuring the Load Balancer Cluster
locate the transportReceiver entries for the HTTP & HTTPS ports and change them to port 80 & 443 respectively. The relevant XML segments are shown below.
- <transportReceiver name="http" class="org.apache.synapse.transport.nhttp.HttpCoreNIOListener">
- <parameter name="port" locked="false">80</parameter>
- <parameter name="non-blocking" locked="false">true</parameter>
- <!--parameter name="bind-address" locked="false">hostname or IP address</parameter-->
- <!--parameter name="WSDLEPRPrefix" locked="false">https://apachehost:port/somepath</parameter-->
- <parameter name="httpGetProcessor" locked="false">org.wso2.carbon.transport.nhttp.api.NHttpGetProcessor</parameter>
- </transportReceiver>
- <!-- the non blocking https transport based on HttpCore + SSL-NIO extensions -->
- <transportReceiver name="https" class="org.apache.synapse.transport.nhttp.HttpCoreNIOSSLListener">
- <parameter name="port" locked="false">443</parameter>
- <parameter name="non-blocking" locked="false">true</parameter>
- <!--parameter name="bind-address" locked="false">hostname or IP address</parameter-->
- <!--parameter name="WSDLEPRPrefix" locked="false">https://apachehost:port/somepath</parameter-->
- <parameter name="httpGetProcessor" locked="false">org.wso2.carbon.transport.nhttp.api.NHttpGetProcessor</parameter>
- <parameter name="keystore" locked="false">
- <KeyStore>
- <Location>repository/resources/security/wso2carbon.jks</Location>
- <Type>JKS</Type>
- <Password>wso2carbon</Password>
- <KeyPassword>wso2carbon</KeyPassword>
- </KeyStore>
- </parameter>
- <parameter name="truststore" locked="false">
- <TrustStore>
- <Location>repository/resources/security/client-truststore.jks</Location>
- <Type>JKS</Type>
- <Password>wso2carbon</Password>
- </TrustStore>
- </parameter>
- <!--<parameter name="SSLVerifyClient">require</parameter>
- supports optional|require or defaults to none -->
- </transportReceiver>
Edit loadbalancer.xml to map the HTTP host to the clustering domain.Add following segment to services section
- <services>
- <defaults>
- <property name="availabilityZone" value="us-east-1c"/>
- <property name="securityGroups" value="default-2011-02-23"/>
- <property name="instanceType" value="m1.large"/>
- <property name="minAppInstances" value="1"/>
- <property name="maxAppInstances" value="5"/>
- <property name="queueLengthPerNode" value="400"/>
- <property name="roundsToAverage" value="10"/>
- <property name="instancesPerScaleUp" value="1"/>
- <property name="messageExpiryTime" value="60000"/>
- </defaults>
- <service>
- <hosts>
- <host>appserver.cloud-test.wso2.com</host>
- </hosts>
- <domain>wso2.as.domain</domain>
- </service>
- </services>
Please note that appserver.cloud-test.wso2.com is mapped to 127.0.0.1 in my machine by changing /etc/hosts entries.Also change carbon.xml file located in appserver repository/conf by adding following entry.
<HostName>appserver.cloud-test.wso2.com</HostName>
Now you have to up and run load balancer product first then run appserver product. You will see following message in loadbalancer log when appserver joins to the load balance cluster.
[2012-02-23 17:34:12,048] INFO - RpcMembershipRequestHandler Received JOIN message from 10.200.2.85:4100(wso2.as.domain)
[2012-02-23 17:34:12,052] INFO - MembershipManager Application member 10.200.2.85:4100(wso2.as.domain) joined group wso2.as.domain
[2012-02-23 17:34:23,062] INFO - DefaultGroupManagementAgent Application member Host:10.200.2.85, Port: 4100, HTTP:9763, HTTPS:9443, ACTIVE:true joined application cluster
Now you can invoke Application server by typing https://appserver.cloud-test.wso2.com:443/carbon/ URL in browser. So you will see the logs related to the requested page in loadbalancer logs.
To remove autoscale you have to remove autoscaler.xml file from wso2lb-1.0.2/repository/deployment/server/synapse-configs/default/tasks folder. Also remove autoscalein and autoscaleout configurations from main.sequence(from main.xml file located in wso2lb-1.0.2/repository/deployment/server/synapse-configs/default/sequences).
No comments:
Post a Comment