This example demonstrates how to deploy Memgraph in a high availability mode with docker compose.
The cluster consists of:
- 3 coordinators (
coord1/coord2/coord3) on bolt ports7691/7692/7693 - 3 data instances (
instance1/instance2/instance3) on bolt ports7687/7688/7689
At startup instance_1 becomes MAIN and the others become REPLICAs.
-
Provide your Memgraph Enterprise license by copying the example env file and filling in your organization name and license key:
cp .env.example .env # then edit .env -
Start the cluster:
docker compose up
Clients connect to the cluster through a coordinator using the Neo4j driver
with the routing-aware neo4j:// scheme. The coordinator hands the driver a
routing table, so write transactions go to the current MAIN and reads can be
served by REPLICAs — and this keeps working across failovers.
The included connect.py connects through one coordinator and runs a small
end-to-end sanity check. Dependencies are managed with uv —
uv run creates the virtual environment and installs the Neo4j driver automatically:
SHOW INSTANCESon the coordinator and assert the whole cluster (6 instances) is present.- Write a node through the coordinator (routed to
MAIN). - Open a direct bolt connection to a
REPLICAand assert the node replicated. - Delete the node through the coordinator.
- Assert the
REPLICAis empty again.
uv run connect.py # connect through coord1 (default)
uv run connect.py coord2 # connect through coord2ℹ️ Coordinator management queries such as
SHOW INSTANCESare not routable, so the script opens a plainbolt://connection to the coordinator for those, and a routedneo4j://connection for the data queries.
This example was built and tested with:
- Memgraph MAGE v3.10.1
If you run into any issues or have questions, feel free to reach out on the Memgraph Discord server. We're happy to help!
🛑 This example requires Memgraph Enterprise.