Monday, November 23, 2015

IBM Websphere MQ clustering - load balancing

These are simple steps on how to cluster IBM Websphere MQ. Clustered MQ requires MQ Manager as gateway and set of MQ Managers as consumers of message. 
Clustering helps improve performance since process can be spread across different applications. Vertical clustering can be used for high-specification machines and horizontal for low-specification machines.

Step 1:

Create gateway queue manager GATEWAYMGR. This is the queue manager that external application will use when sending a message. 




















































Step 2: 
Create two or more MQ manager consumers, e.g. ConsumerMgr1 and ConsumerMgr2.







































Step 3:
Create cluster queue manager, e.g. CLUSTERMGR. Select GATEWAYQMGR as first full repository and ConsumerMgr1 as second full repository.































Step 4:
Create partial repository. Right-click on cluster manager and add queue manager ConsumerMgr2.




























Step 5:
Create local queue to in both ConsumerMgr1 and ConsumerMgr2. 































Step 6:
Create local queue in GATEWAYQMGR with attribute SYSTEM.CLUSTER.TRANSMIT.QUEUE. Message sent to Q.LOC of GATEWAYQMGR will go to either ConsumerMgr1 or 2.




Saturday, November 21, 2015

Clustering/Load balancing using Apache HTTP server

Simple step to cluster Web Service using Apache HTTP server. The HTTP server act as a load balancer for 2 or more resources.









A. Ensure that the following modules are enabled.
  LoadModule actions_module modules/mod_actions.so
  LoadModule alias_module modules/mod_alias.so
  LoadModule allowmethods_module modules/mod_allowmethods.so
  LoadModule asis_module modules/mod_asis.so
  LoadModule auth_basic_module modules/mod_auth_basic.so
  LoadModule authn_core_module modules/mod_authn_core.so
  LoadModule authn_file_module modules/mod_authn_file.so
  LoadModule authz_core_module modules/mod_authz_core.so
  LoadModule authz_groupfile_module modules/mod_authz_groupfile.so
  LoadModule authz_host_module modules/mod_authz_host.so
  LoadModule authz_user_module modules/mod_authz_user.so
  LoadModule autoindex_module modules/mod_autoindex.so
  LoadModule cgi_module modules/mod_cgi.so
  LoadModule dir_module modules/mod_dir.so
  LoadModule env_module modules/mod_env.so
  LoadModule include_module modules/mod_include.so
  LoadModule info_module modules/mod_info.so
  LoadModule isapi_module modules/mod_isapi.so
  LoadModule lbmethod_byrequests_module modules/mod_lbmethod_byrequests.so
  LoadModule log_config_module modules/mod_log_config.so
  LoadModule mime_module modules/mod_mime.so
  LoadModule negotiation_module modules/mod_negotiation.so
  LoadModule proxy_module modules/mod_proxy.so
  LoadModule proxy_balancer_module modules/mod_proxy_balancer.so 
  LoadModule proxy_html_module modules/mod_proxy_html.so
  LoadModule proxy_http_module modules/mod_proxy_http.so
  LoadModule setenvif_module modules/mod_setenvif.so
  LoadModule slotmem_shm_module modules/mod_slotmem_shm.so
  LoadModule socache_shmcb_module modules/mod_socache_shmcb.so
  LoadModule ssl_module modules/mod_ssl.so
  LoadModule status_module modules/mod_status.so
  LoadModule xml2enc_module modules/mod_xml2enc.so


B. Add httpd-proxy-balancer.conf.
  Include conf/extra/httpd-proxy-balancer.conf

C. Create httpd-proxy-balancer.conf inside extra folder.
<VirtualHost *>
    #--- Set to Off since it is not request forwarder.
     ProxyRequests Off
    #--- Display load balance status.
     ProxyStatus On
    #--- Not passing request to proxied host.
     ProxyPreserveHost Off
     ProxyPass /balancer-manager !
     ProxyPass /server-status !
    #-- Balancer cluster name.
     ProxyPass / balancer://mycluster/ STICKYSESSION=mysticky_session nofailover=Off
    #-- Logging.
     CustomLog C:/Apache24/logs/balancer_log.txt combined
    #-- Use as gateway.
     ProxyPassReverse / balancer://mycluster
 
    #-- Cluster / balancer.
     <Proxy balancer://mycluster>
      BalancerMember http://{hostname}:{port} route=first loadfactor=5
      BalancerMember http://{hostname}:{port} route=second loadfactor=5
    </Proxy>
 
    <Location /balancer-manager>
     SetHandler balancer-manager
    </Location>
 
    <Location /server-status>
     SetHandler server-status
    </Location>
</VirtualHost>
D. Start Apache HTTP server.
/bin/httpd.exe
E. Access the application via port 80 if using default port.
http://{host name}:{port}/{app web-context}
F. Status of balancer can be checked from accessing Balance Manager URL.
  http://{hostname}:{port}/balancer-manager