How to setup a simple cluster of OFBiz instances with a load balancer and failover; getting some insights on the architecture; setting up an environment useful for tests and experiments.
A load balancer: we will use HAProxy
OFBiz: we will use the OFBiz trunk (but the same setup will work for any version of OFBiz)
At least three hosts, whose IP addresses will be needed to complete the setup and perform the experiments:
HOST_0: for the load balancer
HOST_1: for the first OFBiz instance of the cluster and for the OFBiz database
HOST_2: for the second OFBiz instance of the cluster (connected to the database in HOST_1)
Download and install HAProxy (load balancer) in Host_0
Setup one database, shared by all OFBiz instances of the cluster, in Host_1
Download and setup (at least) two instances of OFBiz in Host_1 and Host_2 (cluster of 2 instances)
Create a configuration file for HAProxy, as illustrated below
Start HAProxy and the two OFBiz instances
Connect to the HAProxy monitor application to make sure that the instances are up and running
Connect from a browser to OFBiz thru the load balancer; start/stop one of the OFBiz instances; etc…
The load balancer in one host accepting connections on OFBiz default ports (8080 and 8443).
Each incoming connection is assigned, according to the “round robin” algorithm, to one of the two OFBiz instances of the cluster. Each instance is in a separate host.
The load balancer implements session stickiness by redirecting the incoming connection from the same IP address to the same instance of the cluster.
The health of each instance of the cluster is checked every 5 seconds and if an instance is not responsive the incoming connections are sent to another instance of the cluster.
The load balancer supports both plain text and encrypted traffic (SSL/TLS), thus supporting HTTP and HTTPs traffic. No encryption/decryption is performed by the load balancer that acts as a “transparent proxy”.
To complete the configuration:
Replace <HOST_1> and <HOST_2> with the IP addresses of the hosts in which the two OFBiz instances of the cluster are
Add additional server elements for each of the instances in your cluster
(optional) change the URI used to test the instance health; in this configuration, it uses the default ecommerce application (/ecommerce/control/main)
Test environment for experiments is now set.
Access Monitoring Tool
To access the monitoring tool browse at http://<HOST_0>/stats (user: admin and password: admin), replace <HOST_0> with the IP address of the host in which HAProxy is installed.
If you use this remember to have a look at Distributed Entity Cache Clear (DCC) Mechanism
If you have any questions, subscribe and post to OFBiz user mailing at: email@example.com.