Access to add and change pages is restricted. See: https://cwiki.apache.org/confluence/display/OFBIZ/Wiki+access

Purpose

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.

Setup Components

  • 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)

 



Steps

  1. Download and install HAProxy (load balancer) in Host_0

  2. Setup one database, shared by all OFBiz instances of the cluster, in Host_1

  3. Download and setup (at least) two instances of OFBiz in Host_1 and Host_2 (cluster of 2 instances)

  4. Create a configuration file for HAProxy, as illustrated below

  5. Start HAProxy and the two OFBiz instances

  6. Connect to the HAProxy monitor application to make sure that the instances are up and running

  7. Connect from a browser to OFBiz thru the load balancer; start/stop one of the OFBiz instances; etc…

HAProxy Configuration

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:

  1. Replace <HOST_1> and <HOST_2> with the IP addresses of the hosts in which the two OFBiz instances of the cluster are

  2. Add additional server elements for each of the instances in your cluster

    1. (optional) change the URI used to test the instance health; in this configuration, it uses the default ecommerce application (/ecommerce/control/main)


HaProxy Configuration
global
log /dev/log local0
log /dev/log local1 notice
chroot /var/lib/haproxy
stats socket /run/haproxy/admin.sock mode 660 level admin
stats timeout 30s
user haproxy
group haproxy
daemon
# Default SSL material locations
ca-base /etc/ssl/certs
crt-base /etc/ssl/private
ssl-default-bind-ciphers ECDH+AESGCM:DH+AESGCM:ECDH+AES256:DH+AES256:ECDH+AES128:DH+AES:ECDH+3DES:DH+3DES:RSA+AESGCM:RSA+AES:RSA+3DES:!aNULL:!MD5:!DSS
ssl-default-bind-options no-sslv3
defaults
      log     global
      mode    http
      option  dontlognull
      timeout http-request 5s
      timeout connect 5s
      timeout server 10s
      timeout client 30s
errorfile 400 /etc/haproxy/errors/400.http
errorfile 403 /etc/haproxy/errors/403.http
errorfile 408 /etc/haproxy/errors/408.http
errorfile 500 /etc/haproxy/errors/500.http
errorfile 502 /etc/haproxy/errors/502.http
errorfile 503 /etc/haproxy/errors/503.http
errorfile 504 /etc/haproxy/errors/504.http
#######################**HTTP**##############################
frontend HTTP_LB
 bind *:80
 reqadd X-Forwarded-Proto:\ http
 compression algo gzip
 compression type text/html text/plain text/javascript application/javascript application/xml text/css
 default_backend HTTP_LB
backend HTTP_LB
 mode http
 stats enable
 stats hide-version
 stats uri /stats
 stats realm Haproxy\ Statistics
 stats auth admin:admin # Credentials for HAProxy Statistic report page.
 balance roundrobin   # Load balancing will work in round-robin process.
 option httpchk GET /ecommerce/control/main HTTP/1.0
 option  httpclose
 option forwardfor
  stick-table type ip size 400k expire 30m                    
  stick on src
  default-server inter 5s
  server ofbiz234 HOST_1:8080 check id 1
  server ofbiz235 HOST_2:8080 check id 2
####################**HTTPS**##########################
frontend HTTPS_LB
  bind :443
  mode tcp
  compression algo gzip
  compression type text/html text/plain text/javascript application/javascript application/xml text/css
  default_backend HTTPS_LB
backend HTTPS_LB
   mode tcp
   balance roundrobin
   option forwardfor
  option httpchk GET /ecommerce/control/main HTTP/1.0
   stick-table type ip size 400k expire 30m   
   stick on src
   default-server inter 5s
   server ofbiz234 HOST_1:8443 check port 8080 id 1
   server ofbiz235 HOST_2:8443 check port 8080 id 2

 

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.


Screen Shot 2016-08-29 at 6.56.10 PM.png

DCC

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: user@ofbiz.apache.org.


  • No labels