Q: How does Cassandra handle cross-region write consistency during a WAN partition when you use LOCAL_QUORUM versus ALL?
Cassandra interview questions on multi-DC consistency: LOCAL_QUORUM vs ALL, NetworkTopologyStrategy, hinted handoff limits and repair after a WAN partition.
Want to master this scenario in a live sandbox? KodeKloud's PostgreSQL Database Administration & High Availability Course covers this exact problem with hands-on terminal drills.
🛠️ Production Runbook & Step-by-Step Resolution
Direct Answer: Cassandra interview questions on multi-region consistency are really CAP theorem questions with a concrete tool in your hand. The interviewer wants to hear that you choose consistency per request, that you know what each level needs from the cluster, and that you know what happens to the data on the far side of the cut after the link returns. I frame the answer around a two-datacenter cluster, dc1 and dc2, each holding three replicas. When the WAN link between them fails, both datacenters are still healthy internally. A write at ALL needs all six replicas and will fail in both regions. A write at LOCAL_QUORUM needs two of the three replicas in the local datacenter and keeps working. The price is that the two sides now diverge, and I need hinted handoff and then repair to converge them. I explain this as a deliberate availability choice for most user-facing paths, with stronger levels reserved for the few operations that must not diverge.
Set replication per datacenter with NetworkTopologyStrategy
Multi-DC clusters use NetworkTopologyStrategy so I can state how many replicas live in each datacenter. SimpleStrategy ignores topology and should not be used outside single-DC development. The datacenter names in the keyspace must match the names reported by the snitch exactly, or replicas will not be placed where I expect.
CREATE KEYSPACE payments
WITH replication = {
'class': 'NetworkTopologyStrategy',
'dc1': 3,
'dc2': 3
};
-- Confirm datacenter names match what the cluster reports
-- $ nodetool status
-- Datacenter: dc1
-- UN 10.0.1.11 ... rack1
-- Datacenter: dc2
-- UN 10.1.1.11 ... rack1
Configure the snitch so the cluster knows its topology
GossipingPropertyFileSnitch is the usual production choice. Each node declares its own datacenter and rack in cassandra-rackdc.properties and shares that through gossip, so I do not maintain a cluster-wide topology file. Drivers should use a datacenter-aware load balancing policy that prefers the local datacenter, otherwise LOCAL_QUORUM requests may be coordinated across the WAN.
# cassandra.yaml
endpoint_snitch: GossipingPropertyFileSnitch
# /etc/cassandra/cassandra-rackdc.properties on a dc1 node
dc=dc1
rack=rack1
# Verify the topology gossip sees
nodetool status
nodetool gossipinfo | grep -E 'DC|RACK'
Compare what each consistency level needs during the partition
With RF 3 in each DC, LOCAL_QUORUM needs 2 local replicas, QUORUM needs 4 of 6 across both datacenters, EACH_QUORUM needs 2 in every datacenter, and ALL needs all 6. During a WAN cut, LOCAL_QUORUM still succeeds in both regions. QUORUM succeeds nowhere, because each side sees only 3 replicas, and EACH_QUORUM and ALL fail. This is the CAP trade in practice: LOCAL_QUORUM favours availability, ALL favours consistency.
cqlsh> CONSISTENCY LOCAL_QUORUM;
cqlsh> INSERT INTO payments.ledger (id, amount) VALUES (uuid(), 42);
-- OK in dc1 and dc2 during the partition
cqlsh> CONSISTENCY ALL;
cqlsh> INSERT INTO payments.ledger (id, amount) VALUES (uuid(), 42);
-- NoHostAvailable / UnavailableException: Cannot achieve consistency level ALL
-- (required 6 replicas, alive 3)
Understand hinted handoff and its time limit
When a replica is unreachable, the coordinator stores a hint and replays it when the node returns. Hints are an optimisation, not a guarantee. They are only kept while the target has been down for less than max_hint_window, which defaults to 3 hours (older versions call it max_hint_window_in_ms, with a value of 10800000). If the partition lasts longer, the coordinator stops writing hints and the data on the far side can only be recovered by repair.
# cassandra.yaml (3 hours; setting name varies by version)
max_hint_window: 3h
# older releases: max_hint_window_in_ms: 10800000
nodetool statushandoff
# Hinted handoff is running
# Pending hint backlog and streaming activity
nodetool tpstats | grep -i hint
nodetool netstats
Repair after the partition heals
Once the link is back, I let hints replay and then run repair on the affected keyspace, especially if the outage exceeded the hint window. Reads at LOCAL_QUORUM will serve each region's own view until convergence, so I tell product teams that cross-region read-your-writes is not guaranteed at this level. For operations that must be globally consistent, I use a stronger level or a lightweight transaction on a small path, and accept the availability cost.
# Run on each node, primary ranges only, for the keyspace that took writes
nodetool repair -pr payments
# Watch progress and streaming
nodetool netstats
grep -i 'repair' /var/log/cassandra/system.log | tail
- NetworkTopologyStrategy places a chosen number of replicas in each datacenter, and the snitch supplies the topology.
- LOCAL_QUORUM needs a majority of local replicas, so both regions keep accepting writes during a WAN partition.
- ALL and EACH_QUORUM need remote replicas and fail, which is the consistency side of the CAP trade.
- Hints cover short outages up to max_hint_window; after that I run repair to converge the datacenters.
Senior hiring managers and bar raisers evaluate how you prioritize during outages. Avoid these common anti-patterns:
- Using ALL for general write traffic in a multi-DC cluster One slow or unreachable remote replica turns into a full write outage for the application.
- Assuming hinted handoff guarantees convergence Hints stop after max_hint_window and can be lost if the coordinator fails, so repair is still required.
- Leaving the driver without a local-datacenter policy Requests can be coordinated in the remote region and pay WAN latency or fail during a partition.
- Mismatching datacenter names between keyspace and snitch Replicas are not placed where the replication map says, and consistency levels behave unpredictably.