Replication Architecture Overview
FalkorDB replication follows a single-primary model: one master instance accepts all writes and asynchronously streams its changes to one or more replicas. Replicas serve read-only traffic, allowing read workloads to scale horizontally and providing a hot standby in case the master fails. Writes always flow through the master, while replicas mirror the master’s state and absorb read traffic. Because replication is asynchronous, replicas may lag the master slightly under heavy write load — see the Best Practices section for tips on monitoring lag.Prerequisites
Before you begin, ensure you have the following:- Docker installed on your machine.
- A working FalkorDB Docker image. You can pull it from Docker Hub.
- Basic knowledge of Docker commands and configurations.
Step 1: Configuring Replication
Replication ensures that your data is available across multiple FalkorDB instances. You configure one instance as the primary (master) and others as replicas. To enable communication between FalkorDB containers, we first need to set up a Docker network.1.1 Creating a Network
First, create a Docker network to allow communication between the FalkorDB nodes.1.2 Setting up the Master Instance
Start the master FalkorDB instance:1.3 Setting up the Replica Instance
Next, start the replica instance:1.4 Configuring Replication
Connect to the replica instance and configure it to replicate data from the master:Step 2: Verifying the Setup
To verify that replication is working correctly:2.1 Insert Data on Master
2.2 Verify Data on Replica
Best Practices
- Read-Only Queries on Replicas: Use
GRAPH.RO_QUERYfor read operations on replicas to prevent accidental writes - Monitor Replication Lag: Check replication status regularly using Redis
INFO replicationcommand - Multiple Replicas: Configure multiple replicas for better read scalability and redundancy
- Network Latency: Place master and replicas in the same network or region for optimal performance
Troubleshooting
If replication is not working:- Verify network connectivity between containers
- Check that the master is accessible from the replica
- Review logs for errors:
docker logs falkordb-replica1
Next Steps
With replication configured, FalkorDB provides high availability and data redundancy. Your data is now synchronized across multiple instances, creating a robust and fault-tolerant environment. For horizontal scalability and distributed graph operations, explore Clustering.Frequently Asked Questions
Can I write to a replica node?
Can I write to a replica node?
No. Replicas are read-only. All write operations must go through the master. Use
GRAPH.RO_QUERY for read operations on replicas to prevent accidental write attempts.How much replication lag should I expect?
How much replication lag should I expect?
Under normal load, replication lag is typically sub-millisecond. Under heavy write load, replicas may lag slightly. Monitor lag with the
INFO replication command on the master.How many replicas can I configure?
How many replicas can I configure?
There is no hard limit. You can add multiple replicas for better read scalability and redundancy. Each replica maintains a full copy of the master data.
What happens if the master goes down?
What happens if the master goes down?
Without a Sentinel or cluster setup, replicas will not automatically promote. Consider using Redis Sentinel or a cluster configuration for automatic failover in production.
Do replicas increase write performance?
Do replicas increase write performance?
No. Replicas only serve read traffic. All writes still go through the single master. To scale writes, consider using a cluster setup to distribute graphs across multiple masters.