Driver Policies: Load Balancing, Retry & Reconnection
Understand how Cassandra client drivers use pluggable policies to route requests, handle failures, and recover from outages.
The driver decides which node to talk to, what to do when that fails, and when to try a dead node again. Those defaults matter more than most application code.
The load balancing policy is like a dispatcher who always tries to route calls to the nearest available support office first. The retry policy is like a rulebook telling the dispatcher exactly when it's safe to redial after a dropped call versus when to just tell the customer it failed. The reconnection policy is like waiting progressively longer between redial attempts to an office that stopped answering, so you don't flood a struggling office with call attempts the moment it goes quiet.
Key Concepts
datastax-java-driver.basic.load-balancing-policy {
local-datacenter = mumbai
} UPDATE users SET email = 'a@x.com' -- safe, same result twice
UPDATE counts SET n = n + 1 -- not safe, counts twice
INSERT ... IF NOT EXISTS -- not safe to blindly retry attempt after 1s, 2s, 4s, 8s ... up to 60s