Database / Apache Cassandra Intermediate and Advanced interview questions
What is speculative retry in Cassandra?
Speculative retry is a per-table setting that helps tame tail latency by not letting the coordinator wait indefinitely on the single slowest replica.
- When the coordinator sends a read to the replicas needed for the consistency level, one of them may occasionally respond slowly due to GC pauses, compaction, or disk contention.
- If a response hasn't come back within a configured threshold, the coordinator speculatively sends the same read to an additional replica, and uses whichever response arrives first.
- The threshold can be a fixed time (e.g.
20ms) or a percentile of that table's observed read latency (e.g.99percentile, which adapts as the table's normal latency shifts).
ALTER TABLE orders WITH speculative_retry = '99percentile';
This trades a small amount of extra read load (occasionally querying one more replica than strictly necessary) for meaningfully better p99/p999 latency, since a single slow node no longer stalls every read that happens to be routed to it.
More Related questions...