This section describes the available endpoints for Neo4j HA clusters.
A common use case for Neo4j HA clusters is to direct all write requests to the master while using slaves for read operations, distributing the read load across the cluster and gaining failover capabilities for the deployment. The most common way to achieve this is to place a load balancer in front of the HA cluster. For a description of HAProxy, see Section E.2.4, “HAProxy for load balancing”. As you can see in that section, it makes use of an HTTP endpoint to discover which instance is the master, and then directs write load to it.
Each HA instance comes with three endpoints regarding its status:
The /master and /slave endpoints can be used to direct write and non-write traffic to specific instances. This is the optimal way to take advantage of Neo4j’s scaling characteristics. The /available endpoint exists for the general case of directing arbitrary request types to instances that are available for transaction processing.
To use the endpoints, perform an HTTP GET
operation.
The table below outlines the possible responses for each endpoint:
Endpoint | Instance State | Returned Code | Body text |
---|---|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
From the command line, a common way to ask those endpoints is to use curl
.
With no arguments, curl
will do an HTTP GET
on the URI provided and will output the body text, if any.
If you also want to get the response code, just add the -v
flag for verbose output. Here are some examples:
#> curl -v localhost:7474/db/manage/server/ha/master
* About to connect() to localhost port 7474 (#0)
* Trying ::1...
* connected
* Connected to localhost (::1) port 7474 (#0)
> GET /db/manage/server/ha/master HTTP/1.1
> User-Agent: curl/7.24.0 (x86_64-apple-darwin12.0) libcurl/7.24.0 OpenSSL/0.9.8r zlib/1.2.5
> Host: localhost:7474
> Accept: */*
>
< HTTP/1.1 200 OK
< Content-Type: text/plain
< Access-Control-Allow-Origin: *
< Transfer-Encoding: chunked
< Server: Jetty(6.1.25)
<
* Connection #0 to host localhost left intact
true* Closing connection #0
#> curl localhost:7474/db/manage/server/ha/slave
false
#> curl -v localhost:7475/db/manage/server/ha/master
* About to connect() to localhost port 7475 (#0)
* Trying ::1...
* connected
* Connected to localhost (::1) port 7475 (#0)
> GET /db/manage/server/ha/master HTTP/1.1
> User-Agent: curl/7.24.0 (x86_64-apple-darwin12.0) libcurl/7.24.0 OpenSSL/0.9.8r zlib/1.2.5
> Host: localhost:7475
> Accept: */*
>
< HTTP/1.1 404 Not Found
< Content-Type: text/plain
< Access-Control-Allow-Origin: *
< Transfer-Encoding: chunked
< Server: Jetty(6.1.25)
<
* Connection #0 to host localhost left intact
false* Closing connection #0
Unknown status | |
---|---|
The |
If authentication and authorization is enabled, the HA status endpoints will also require authentication credentials.
For some load balancers and proxy servers, providing this with the request is not an option.
For those situations, consider disabling authentication of the HA status endpoints by setting dbms.security.ha_status_auth_enabled=false
in the neo4j.conf
configuration file.