Skip to content

HA and Load Balancing

Liesware edited this page Oct 1, 2019 · 9 revisions

HA and Load Balancing

Processes

Some of operations on Cryptography are very CPU-intensive, so to scale on a machine the recommendation is:

  • Coherence processes= Total_cpu_cores - 2
  • The remaining cores, one is for HAProxy and one is for system.

This parameters depends on your own needs.

The balance algorithm depends on if your code keeps the connection open or close on each operation. If the client close the connection on each request roundrobin works fine, an example for this config on HAProxy is:

global
    log         127.0.0.1 local2
    chroot      /var/lib/haproxy
    pidfile     /var/run/haproxy.pid
    maxconn     4000
    tune.bufsize 128000
    user        haproxy
    group       haproxy
    daemon
    stats socket /var/lib/haproxy/stats

frontend Coherence
    bind 0.0.0.0:6613
    mode http
    option httplog
    timeout client  1m
    balance roundrobin
    default_backend Coherence-HA

backend Coherence-HA
    option tcp-check
    server node1 127.0.0.1:6614 check port 6614
    server node2 127.0.0.1:6615 check port 6615

If the connection is long-term, persistence is ok, you can use stick-table or ip hash.

global
    log         127.0.0.1 local2
    chroot      /var/lib/haproxy
    pidfile     /var/run/haproxy.pid
    maxconn     4000
    tune.bufsize 128000
    user        haproxy
    group       haproxy
    daemon
    stats socket /var/lib/haproxy/stats

frontend Coherence
    bind 0.0.0.0:6613
    mode tcp
    option tcplog
    timeout client  1m
    balance source
    hash-type consistent
    #stick-table type ip size 50k expire 60m
    #stick on src
    default_backend Coherence-HA

backend Coherence-HA
    option tcp-check
    server node1 127.0.0.1:6614 check port 6614
    server node2 127.0.0.1:6615 check port 6615
Clone this wiki locally