What is a coordinator node in Cassandra?
Understand the Cassandra coordinator node: the per-request role that routes reads and writes to replicas, enforces consistency levels and handles failures.
Expected Interview Answer
A coordinator node in Cassandra is simply the node that a client happens to connect to for a given request; it takes responsibility for routing that read or write to the correct replica nodes and returning the result to the client.
Any node can act as coordinator because the ring is masterless — the role is per-request, not a fixed server. The coordinator uses the partition key and the partitioner to determine which nodes own the replicas, forwards the operation to them, applies the requested consistency level to decide how many must respond, and handles failures with mechanisms like hinted handoff. Drivers use token-aware and load-balancing policies to pick coordinators wisely, often the replica itself, to minimize extra network hops.
- Any node can serve as coordinator, spreading load
- Clients need not know replica placement
- Enforces the request's consistency level
- Manages retries and hinted handoff on failure
- Token-aware drivers reduce network hops
AI Mentor Explanation
Think of the coordinator as whichever fielder the ball is thrown to first — that player becomes responsible for relaying it to the right teammate near the stumps. Any fielder can take on this relay duty for a given ball; it is not a fixed role. In Cassandra any node the client contacts becomes the coordinator, routing that one request to the replicas that actually hold the data.
Step-by-Step Explanation
Step 1
Client connects
The driver opens a connection to one node in the cluster, which becomes the coordinator for that request.
Step 2
Locate replicas
The coordinator hashes the partition key with the partitioner to find which nodes own the replicas for that data.
Step 3
Dispatch the request
It forwards the read or write to the relevant replica nodes across the ring.
Step 4
Apply consistency level
It waits for the required number of replicas (e.g., QUORUM) to acknowledge before responding.
Step 5
Return and repair
It returns the result to the client and triggers read repair or hinted handoff when replicas disagree or are down.
What Interviewer Expects
- Coordinator is a per-request role, not a fixed node
- Any node can coordinate because the ring is masterless
- How the coordinator locates replicas via the partitioner
- Its role in enforcing consistency levels
- Awareness of token-aware driver policies
Common Mistakes
- Thinking the coordinator is a dedicated master server
- Believing only one fixed node coordinates all requests
- Confusing coordinator with the partitioner or seed nodes
- Ignoring token-aware routing that avoids extra hops
- Assuming the coordinator stores the data itself
Best Answer (HR Friendly)
“The coordinator is just the Cassandra server your app happens to talk to for a request. It figures out which servers actually hold the data, asks them to do the read or write, and hands the answer back — and any server can play this role.”
Code Example
from cassandra.cluster import Cluster
from cassandra.policies import TokenAwarePolicy, DCAwareRoundRobinPolicy
cluster = Cluster(
['10.0.0.1', '10.0.0.2'],
load_balancing_policy=TokenAwarePolicy(DCAwareRoundRobinPolicy())
)
session = cluster.connect('store')
# driver routes to a replica-owning node as coordinator
session.execute('SELECT * FROM orders WHERE order_id=%s', [42])Follow-up Questions
- Can any node in the cluster act as a coordinator?
- How does a token-aware policy pick a better coordinator?
- What does the coordinator do when a replica is unavailable?
- How does the coordinator enforce the consistency level?
- What is the difference between a coordinator node and a seed node?
MCQ Practice
1. Which node acts as the coordinator for a Cassandra request?
The coordinator role is per-request and belongs to whatever node the client contacts, since the cluster is masterless.
2. What is a primary job of the coordinator node?
The coordinator locates replicas, forwards the operation, applies the consistency level, and returns the result.
3. Why do drivers use a token-aware load balancing policy?
Token-aware routing sends the request directly to a replica-owning node, reducing an extra forwarding hop.
Flash Cards
What is a coordinator node? — The node a client connects to for a request; it routes the operation to the correct replicas and returns the result.
Is the coordinator a fixed node? — No — it is a per-request role, and any node can coordinate because Cassandra is masterless.
How does the coordinator find replicas? — It hashes the partition key with the partitioner to identify which nodes own the data.
What is token-aware routing? — A driver policy that sends requests to a replica-owning node, making it the coordinator and saving a hop.