Skip to content

Instantly share code, notes, and snippets.

@edubxb
Last active September 11, 2015 14:49
Show Gist options
  • Save edubxb/f451248a7ff3204a2a96 to your computer and use it in GitHub Desktop.
Save edubxb/f451248a7ff3204a2a96 to your computer and use it in GitHub Desktop.
HAproxy config to balance reads and writes in a Neo4j cluster (2 nodes, one arbiter)
global
log 127.0.0.1 local2
chroot /var/lib/haproxy
pidfile /var/run/haproxy.pid
user haproxy
group haproxy
daemon
stats socket /var/lib/haproxy/stats
defaults
mode http
log global
option httplog
option dontlognull
option forwardfor except 127.0.0.0/8
option redispatch
maxconn 256
retries 3
timeout connect 5000ms
timeout client 50000ms
timeout server 50000ms
frontend neo4j
bind *:7474
acl elb_check url_beg /db/manage/server/ha/available
acl no_slaves nbsrv(neo4j-slaves) eq 0
acl master_methods method POST DELETE PUT
acl slave_methods method GET
use_backend neo4j-nodes if elb_check
use_backend neo4j-masters if master_methods
use_backend neo4j-masters if no_slaves
use_backend neo4j-slaves if slave_methods
default_backend neo4j-nodes
backend neo4j-masters
balance first
option httpchk GET /db/manage/server/ha/master
server neo4j-1 neo4j-1:7474 maxconn 32 check
server neo4j-2 neo4j-2:7474 maxconn 32 check
backend neo4j-slaves
balance first
option httpchk GET /db/manage/server/ha/slave
server neo4j-1 neo4j-1:7474 maxconn 32 check
server neo4j-2 neo4j-2:7474 maxconn 32 check
backend neo4j-nodes
balance roundrobin
option httpchk GET /db/manage/server/ha/available
server neo4j-1 neo4j-1:7474 maxconn 32 check
server neo4j-2 neo4j-2:7474 maxconn 32 check
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment