Skip to content

HA and Load Balancing

Liesware edited this page Apr 9, 2019 · 7 revisions

HA and Load Balancing

In order to scale Coherence , we need to consider these facts:

  • Coherence is stateless
  • Coherence binds on one TCP port
  • Coherence closes the connection only when we client closes the connection
  • Coherence uses a buffer size of suggested_size 65536
  • Coherence receives data in one-shot and performs the operation

The main point is the load balancer has the same buffer size as Coherence, for HAproxy the parameter is:

tune.bufsize 128000

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.

HAProxy

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 tcp
    option tcplog
    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
You can’t perform that action at this time.