This document provides guidance on moving Neo4j graphs to production environments. It discusses solution architectures, hardware and software requirements, high availability configurations, backups, monitoring, and testing. Server, embedded, and server with procedures deployment architectures are covered. The document provides recommendations for optimizing performance on AWS, configuring load balancing, and scaling Neo4j horizontally.
10. Local Storage
• SSD or HDD
• Highest I/O performance
• Included in virtual server
• Up to 8 x 800 GB SSD (i2.8xlarge) or 24 x 2000 GB HDD (d2.8xlarge)
• Lost when EC2 instance is terminated
Elas3c Block Store (EBS)
• AUached to EC2 instance via network connec%on
• Up to 16 TB SSD
• Persist even if EC2 instance is terminated
• Use EBS-op%mized EC2 instances for dedicated throughput to EBS
• Provisioned IOPS (io1) for predictable performance
• Up to 30 IOPS per GiB
– E.g. 300 GiB volume, 9000 IOPS
12. Cluster Configura3on
Joining Cluster
• ha.initial_hosts (neo4j.conf)
• List of servers to contact when joining cluster
• All hosts must be available when star%ng instance
• For large clusters, supply only a small number of hosts, e.g. 3
Pull and Push Transac3ons
• ha.pull_interval=10s (off by default)
• ha.tx_push_factor=1 (default, but best efforts only)
Tuning
• ha.heartbeat_timeout=11s (default)
• Heartbeats sent, by default, every 5s
• Increase %meouts if pauses cause heartbeats to be delayed
• Warning: it will take longer to discover an instance has failed
• ha.role_switch_timeout=120s (default)
• Increase if new instances %meout while catching up with master on startup
13. HA Role Endpoints – Useful for Load Balancing
Endpoint State Status Code Body
/db/manage/server/ha/master
Master 200 OK true
Slave 404 Not Found false
Unknown 404 Not Found UNKNOWN
/db/manage/server/ha/slave
Master 404 Not Found false
Slave 200 OK true
Unknown 404 Not Found UNKNOWN
/db/manage/server/ha/available
Master 200 OK master
Slave 200 OK slave
Unknown 404 Not Found UNKNOWN
From 2.3 onwards
dbms.security.ha_status_auth_enabled=false
neo4j.conf
14. HA JMX Endpoint
JSON Response
• Alive?
• Role
• Last commiUed transac%on ID
• Instances in cluster
• Role
• Instance ID
• Available?
• URI
Iden%fy slaves
falling behind
Does everyone agree
on composi%on of
cluster?
/db/manage/server/jmx/domain/org.neo4j/instance%3Dkernel%230%2Cname%3DHigh%20Availability
22. Cache Sharding Using Consistent Rou3ng
Applica%on
1 2 3
Load Balancer
MATCH (c:Country{name:'Australia'})...MATCH (c:Country{name:'Zambia'})...MATCH (c:Country{name:'Norway'})...
A-I 1
J-R 2
S-Z 3
MATCH (c:Country{name:'Zambia'})...MATCH (c:Country{name:'Norway'})...MATCH (c:Country{name:'Australia'})...
23. Configure HAProxy for Cache Sharding
global
daemon
maxconn 256
defaults
mode http
timeout connect 5000ms
timeout client 50000ms
timeout server 50000ms
frontend http-in
bind *:80
default_backend neo4j-slaves
backend neo4j-slaves
balance url_param country_code
server s1 10.0.1.10:7474 maxconn 32
server s2 10.0.1.11:7474 maxconn 32
server s3 10.0.1.12:7474 maxconn 32
listen admin
bind *:8080
stats enable
24. Configure HAProxy for Cache Sharding
global
daemon
maxconn 256
defaults
mode http
timeout connect 5000ms
timeout client 50000ms
timeout server 50000ms
frontend http-in
bind *:80
default_backend neo4j-slaves
backend neo4j-slaves
balance url_param country_code
server s1 10.0.1.10:7474 maxconn 32
server s2 10.0.1.11:7474 maxconn 32
server s3 10.0.1.12:7474 maxconn 32
listen admin
bind *:8080
stats enable
25. Backups
Modes
• Full
• Incremental
• On top of a previous backup
• Uses logical logs to apply changes, so logs must be kept at least 2 x backup interval
Consistency Check
• Part of full backup and standalone tool
• Evaluate store health
• -verify false to disable in backup
dbms.tx_log.rotation.retention_policy=7 days (default)
neo4j.conf