Skip to content

AxonOps — AI-Native Control Plane for Open Source Data Platforms

Cassandra SEDA Architecture

Cassandra executes work in stages. Each stage is one type of work, with its own fixed-size thread pool and its own queue, and stages hand work to each other through the messaging layer. The design bounds how many threads a node runs, holds concurrency in queues rather than in threads, and gives each type of work its own counters.

This page describes the model. The pools that implement it are catalogued in Thread Pools, with the setting that sizes each one and the meaning of a backlog on it.


A thread per in-flight request does not scale on a storage node. Each thread holds a stack, 256KB on a Cassandra node, since the shipped jvm-server.options sets -Xss256k on 5.0, 4.1 and 4.0 in place of the JVM default of around 1MB on 64-bit Linux. The operating system also has to switch between threads that are mostly waiting on a disk or on a peer, so a node carrying thousands of concurrent requests spends an increasing share of its CPU on scheduling.

A staged design bounds that cost:

  • Each stage has a small thread pool, sized for the resource that type of work consumes, which keeps the number of runnable threads close to the number of cores.
  • Concurrency is held in queues rather than in threads, so ten thousand in-flight requests are ten thousand queue entries rather than ten thousand stacks.
  • Splitting a request into stages lets parts of different requests run at the same time.
  • Work that has waited in a queue past the timeout of its message is dropped instead of executed, which keeps a node that is behind from spending its capacity on results nobody is still waiting for.

Splitting by work type also isolates resources. A stage waiting on disk occupies only its own threads, so slow reads do not take capacity from writes and compaction does not take capacity from queries. Because each stage counts its own work, a queue identifies which type of work is behind.

Fixed pool sizes also set the shape of overload. The number of runnable threads does not rise with the arrival rate, so scheduling cost stays flat and completed throughput levels off near the capacity of the node rather than falling away as load continues to increase. What a node past its saturation point does with the excess work is covered in Behaviour when a stage cannot keep up.

Cassandra 5.0, 4.1 and 4.0 all execute work this way. The proposed move to a thread-per-core model (CASSANDRA-10989) is open and has not shipped.

SEDA ModelSEDA ModelStage A×8 threadsStage B×32 threadsStage C×4 threadsqueuequeue

A CQL request flows through multiple stages from arrival to response:

CQL request flow through SEDA stagesCQL request flow through SEDA stagesClientNative-Transport×128 threadsRequestResponsecoordinatorReadStage×32 threadsMutationStage×32 threadsresponseresultack

Each stage consists of a queue and a thread pool:

SEDA stage composed of a queue and a thread poolSEDA stage composed of a queue and a thread poolSEDA StageQueuepending_tasksThread Pool×N threadsdequeue
ComponentMetricDescription
Queuepending_tasksTasks waiting for a thread
Thread Poolactive_tasksCurrently executing tasks
Thread Poolactive_tasks_limitPool size (max concurrent)
Countercompleted_tasksTotal completed since startup
Counterblocked_tasks, blocked_tasks_all_timeSubmissions the pool made to wait or refused. Both stay at zero on the request stages on 5.0, 4.1 and 4.0

A stage that is handed work faster than it can complete it accumulates pending_tasks. On 5.0, 4.1 and 4.0 the submitting thread enqueues the task and returns; it is not made to wait for room, and the request stages queue without a length limit. A stage that falls behind therefore presents as a growing queue and rising latency rather than as a stalled caller.

The queue is bounded by time rather than by length. Every internode message carries a verb, and each verb has a timeout taken from the matching request timeout in cassandra.yaml, for example read_request_timeout at 5s and write_request_timeout at 2s. A message still waiting when its timeout expires is dropped instead of executed, because the coordinator that sent it has already given up on the answer. Sustained pending_tasks on a stage and a rising drop count for that stage’s verb are the same condition observed at two points.

Saturated stage: queue growth and dropped messagesSaturated stage: queue growth and dropped messagesClientNative transportbytes in flight limitedStage queuepending: risingStage threadsall busyShed at the transportOverloadedExceptionDroppedpast the verb timeoutrequestsubmit, without waitingdequeuein-flight bytes orrequest deadline exceededwaited past the timeout

The blocked counters are not the saturation signal

Section titled “The blocked counters are not the saturation signal”

On 5.0, 4.1 and 4.0 a full queue does not stall its submitter; that behaviour was removed from the shared executor before 4.0 was released (CASSANDRA-16186). nodetool tpstats and system_views.thread_pools still report blocked_tasks and blocked_tasks_all_time, and both stay at zero for every pool on the read, write and client request path. An alert written on either counter for those pools cannot fire. Thread Pools states which pools can move blocked_tasks_all_time on 5.0 and 4.1, and what to read in its place.

The queue itself is what a saturated stage shows:

-- Read every stage, then pick out the ones carrying a queue
SELECT name, active_tasks, active_tasks_limit, pending_tasks
FROM system_views.thread_pools;

CQL has no OR in a WHERE clause, so the stages of interest are picked out of the full result. The thread_pools virtual table covers the columns and the queries against it.

What limits the client request path (5.0, 4.1 and 4.0)

Section titled “What limits the client request path (5.0, 4.1 and 4.0)”

The native transport layer limits the volume of in-flight request data, in bytes, on 5.0, 4.1 and 4.0:

cassandra.yaml
# Total bytes allowed in flight (node-wide)
# Cassandra 4.1+: native_transport_max_request_data_in_flight (auto-calculated ~1/10 heap)
# Cassandra 4.0: native_transport_max_concurrent_requests_in_bytes
native_transport_max_request_data_in_flight: # auto (default)
# Bytes allowed per client IP
# Cassandra 4.1+: native_transport_max_request_data_in_flight_per_ip (auto-calculated ~1/40 heap)
# Cassandra 4.0: native_transport_max_concurrent_requests_in_bytes_per_ip
native_transport_max_request_data_in_flight_per_ip: # auto (default)
# Response when overloaded
# false: Apply TCP backpressure (recommended)
# true: Return OverloadedException immediately
native_transport_throw_on_overload: false

When limits are exceeded:

  • throw_on_overload: false (default): Stops reading from client sockets, TCP buffers fill, client naturally slows down
  • throw_on_overload: true: Returns OverloadedException immediately, client must handle

That limit counts bytes in flight. A second mechanism sheds on time: in 5.0 and in 4.1.6 and later, each native transport request carries a deadline set by native_transport_timeout, 12000ms by default, and a request older than its deadline is rejected with an OverloadedException that names queue time as the reason (CASSANDRA-19534). Neither mechanism bounds the number of queued requests, and a node can reach either one without reaching the other. Thread Pools covers the transport pools.


Each stage reports the tasks it is running and the tasks queued behind them. Those counters, read together with the dropped message counts, are the evidence for locating a bottleneck by work type.

Terminal window
nodetool tpstats
SELECT name, active_tasks, pending_tasks, completed_tasks
FROM system_views.thread_pools;

Thread Pools covers what each counter means, every pool a node reports, the settings that size them, and the executors that run work but report nothing.


The staged event-driven model was described in a 2001 SOSP paper by Matt Welsh, David Culler and Eric Brewer, which addressed servers with few cores that had to serve thousands of concurrent connections. Cassandra has used the model since its first releases, and still does.