Configuration Settings for an Apache Load-Balanced Hybris Cluster

This tutorial demonstrates the configuration details for a two node, load-balanced Hybris cluster using Apache Web Server.

 

Steps

Step 1

Configure Node1's local.properties file to resemble the following:

yacceleratorstorefront.webroot=
storefrontContextRoot=
#Cluster
clustermode=true
cluster.id=1
cluster.maxid=2
cluster.broadcast.methods=jgroups
cluster.broadcast.method.jgroups=de.hybris.platform.cluster.jgroups.JGroupsBroadcastMethod
cluster.broadcast.method.jgroups.tcp.bind_addr=127.0.0.1
cluster.broadcast.method.jgroups.tcp.bind_port=7800
cluster.broadcast.method.jgroups.channel.name=hybris-broadcast
cluster.broadcast.method.jgroups.configuration=jgroups-tcp.xml
cluster.broadcast.method.udp.multicastaddress=230.0.0.1
cluster.broadcast.method.udp.port=9997
log4j.logger.de.hybris.platform.cluster.PingBroadcastHandler=DEBUG
log4j.logger.de.hybris.platform.cluster.udp.UnicastBroadcastMethod=DEBUG

 

Step 2

Configure Node2's local.properties file to resemble the following:

yacceleratorstorefront.webroot=
storefrontContextRoot=
 
#Cluster
clustermode=true
cluster.id=2
cluster.maxid=2
cluster.broadcast.methods=jgroups
cluster.broadcast.method.jgroups=de.hybris.platform.cluster.jgroups.JGroupsBroadcastMethod
cluster.broadcast.method.jgroups.tcp.bind_addr=127.0.0.1
cluster.broadcast.method.jgroups.tcp.bind_port=7800
cluster.broadcast.method.jgroups.channel.name=hybris-broadcast
cluster.broadcast.method.jgroups.configuration=jgroups-tcp.xml
cluster.broadcast.method.udp.multicastaddress=230.0.0.1
cluster.broadcast.method.udp.port=9997
log4j.logger.de.hybris.platform.cluster.PingBroadcastHandler=DEBUG
log4j.logger.de.hybris.platform.cluster.udp.UnicastBroadcastMethod=DEBUG
tomcat.http.port=10001
tomcat.ssl.port=10002
tomcat.ajp.port=10009
tomcat.ajp.ssl.port=10010
tomcat.jmx.port=10003
tomcat.jmx.server.port=10004

 

Step 3

Edit the Apache Web Server httpd.conf file to include the following:

Header add Set-Cookie: "ROUTEID=.%{BALANCER_WORKER_ROUTE}e; path=/" env=BALANCER_ROUTE_CHANGED
 
<Proxy balancer://mycluster>
BalancerMember http://127.0.0.1:9001 route=node1
BalancerMember http://127.0.0.1:10001 route=node2
</Proxy>
 
ProxyPass / balancer://mycluster/ stickysession=ROUTEID
ProxyPassReverse / balancer://mycluster/
 
<Location /balancer-manager>
SetHandler balancer-manager
 
Order Deny,Allow
Deny from all
Allow from all
</Location>
For my information on load balancing with Apache: https://httpd.apache.org/docs/2.4/mod/mod_proxy_balancer.html

*This article was inspired by a previous article written by John B. from Hybris.

Marc Raygoza

Marc is the Founder of HybrisArchitect.com.
He enjoys helping others learn more about SAP Hybris Commerce.
Marc has held the role of Hybris Architect at Exemplis and Nasty Gal. He is a long-time Java/Spring developer. Marc holds an M.S. Software Engineering from Carnegie Mellon University and a B.S. in Accountancy from California State University, Fresno. He can be reached at: info@hybrisarchitect.com

You may also like...

Popular Posts

5 Comments

  1. Hi March,
    Can you explain binding address , is it common network address for all cluster node as we have four cluster node.can you help how we resolved below issue
    INFO | jvm 1 | srvmain | 2018/02/02 05:47:43.750 | ERROR [ ] - [AfterSaveEventPublisher-master] [JGroupsBroadcastMethod] Error during jgroups initialization:
    INFO | jvm 1 | srvmain | 2018/02/02 05:47:43.750 | java.net.BindException: [TCP] /11.111.01.02 is not a valid address on any local network interface

    1. Hi Mahabir,

      Thank you for your comment.

      First question, do you see the correct Hybris nodes listed in HAC under Monitoring --> Cluster ?

      Another thing to consider is that often multicast traffic uses IPV6 network interfaces even if IPV4 address was specified. Please make sure the JVM is using IPV4 by adding the following setting to the local.properties:

      tomcat.javaoptions=-Djava.net.preferIPv4Stack=true -Djava.net.preferIPv6Addresses=false

      Please keep me updated on this issue.

      Thanks
      Marc

  2. Hi Mac,

    Still we are getting the same issue after using above mentioned configuration
    I want just to know what is function of bind_addr . it is the IP address of the hybris cluster node or network adddress which is common for all cluster node.
    cluster.broadcast.method.jgroups.tcp.bind_addr= 127.0.0.1

    1. Hi Mahabir,

      This depends on how your network is setup, but first try changing the bind_addr to the IP Address of the Hybris cluster node.

      Marc

  3. Hello Marc,

    How to configure session fail-over on hybris platform?

    I tried run two nodes in cluster using you example and "session.replication.support=true" in "config/local.properties"

    Are there anything else needed except this option?
    Do we need to configure Tomcat cluster with SimpleTcpCluster (https://tomcat.apache.org/tomcat-7.0-doc/cluster-howto.html)

Leave a Reply

Your email address will not be published. Required fields are marked *