Decouple the control plane (system streams) from the data plane on executor receive queues
This is a follow-up extracted from the review discussion on #8593 . During that review it was pointed out that the control plane and the data plane currently share the same executor receive queue, and that under heavy load the producer-side buffering of data tuples makes the control plane less responsive. This issue tracks that problem on its own so we can discuss and evaluate the options properly.
Two different traffic types
A Storm executor multiplexes two fundamentally different kinds of traffic onto its single inbound
JCQueue ("receive-queue"):
- Data plane: the actual business tuples flowing between components. High volume, bursty, and the traffic that backpressure is meant to throttle.
- Control plane (system streams): low-volume, coordination tuples that keep the topology healthy and responsive.
Storm reserves the __ prefix for these internal streams. The full set:
| Stream ID | Constant | Defined in | Purpose |
|---|---|---|---|
__system |
SYSTEM_STREAM_ID |
StormCommon.java |
System stream (startup / coordination). |
__tick |
SYSTEM_TICK_STREAM_ID |
Constants.java |
Tick tuples, drive tick-based logic and timeouts. |
__flush |
SYSTEM_FLUSH_STREAM_ID |
Constants.java |
Flush tuples , drive the batch flush. |
__metrics |
METRICS_STREAM_ID |
Constants.java |
Metrics data stream. |
__metrics_tick |
METRICS_TICK_STREAM_ID |
Constants.java |
Metrics tick, drives metrics collection / telemetry. |
__ack_init |
ACKER_INIT_STREAM_ID |
Acker.java |
Acker: anchor/init for a new tuple tree. |
__ack_ack |
ACKER_ACK_STREAM_ID |
Acker.java |
Acker: ack acknowledgements. |
__ack_fail |
ACKER_FAIL_STREAM_ID |
Acker.java |
Acker: failure notifications. |
__ack_reset_timeout |
ACKER_RESET_TIMEOUT_STREAM_ID |
Acker.java |
Acker: reset the tuple-tree timeout. |
__heartbeat |
HEARTBEAT_STREAM_ID |
ShellBolt.java |
Multilang/shell component heartbeats. |
__eventlog |
EVENTLOGGER_STREAM_ID |
StormCommon.java |
Event logger stream (debug/eventlogging). |
These have opposite requirements from the data plane: the data plane wants throughput and is expected to be throttled under load. The control plane, on the other hand, does not need the lowest possible latency, what it needs is a delivery guarantee with bounded, jitter-free latency. In other words, control tuples must be delivered within a predictable, stable time bound that does not degrade as the data plane saturates. A control signal that arrives a little later but always within a known bound is far more useful than one that is usually fast but occasionally stalls behind a data backlog: the coordination logic (timeouts, ticks, the flush feedback loop) depends on consistency, not raw speed.
Current behavior: they share the same queue
There is one JCQueue per executor, and every inbound tuple, data and control alike, goes through it. Note that the flush tuple already uses tryPublishDirect to bypass producer-side batching, but it is still appended to the same MPSC recvQueue, so it is delivered FIFO behind whatever data backlog is already enqueued.
Why this is a problem
Because the two planes share one FIFO queue, data-plane ingestion directly degrades control-plane responsiveness: the data plane can starve or delay the control plane, which is the opposite of what we want. Control-plane traffic should be insulated from data-plane buffering and saturation.
I am adding the first proposal for this braimstorming process: instead of a single JCQueue, each executor is assigned two separate instances: a data queue and a control queue.
Classification: Upon ingestion, the incoming tuple is evaluated by its source stream id. If it belongs to one of the reserved __ system streams, it is routed to the control queue; otherwise, it is directed to the data queue. Prioritization: During every consumption cycle, the consumer drains the control queue first (or applies a heavy processing weight to it) before handling the data queue.
This approach creates a physical separation for the control plane, rendering it immune to data-plane backpressure, overflow, and backlogs. This directly achieves our goal, however, it introduces a strict requirement: the ingestion path must read and inspect every tuple's stream prior to enqueuing.
Pros
- Control Plane Isolation: Because the control queue utilizes a dedicated buffer, it cannot be blocked, delayed, or dropped by data backlogs. This guarantees minimal control-plane jitter even under complete data-plane saturation.
- Independent Configuration: The control queue can be minimally sized, with a dynamic batch size, and entirely exempt from standard overflow or backpressure (BP) machinery. Meanwhile, the data queue maintains its existing overflow and BP semantics without modification.
- Consumption Logic: A "drain control first" policy is highly predictable, simple to reason about, and easy to verify. Given that control traffic is inherently low-volume, the risk of starving the data plane is negligible in practice.
- Negligible Cost on Primary Ingress: For remote tuples, deserialization is already completed by DeserializingConnectionCallback before reaching transferLocalBatch (WorkerState.java:240). Consequently, calling getSourceStreamId() for classification is a cheap field access rather than an expensive deserialization step.
Cons
- Overhead on the Hot Path: Inspecting every tuple adds an extra conditional branch and processing step directly on the critical ingestion paths. Additionally, the definition of what constitutes a "control stream" must be strictly centralized to prevent logic drift as new system streams are introduced.
- Memory and bookkeeping footprint: Doubling the queue instances per executor doubles the underlying buffers, queue metrics, and the per-producer-thread batcher footprint.
- Potential Starvation Risks: While "control first" scheduling is simple, it requires safeguards to ensure a sudden, hypothetical burst of system traffic cannot indefinitely stall data processing.
Thanks for writing this up. I went through the relevant code paths and I think the problem is actually a bit broader than described. There are three distinct failure modes today:
-
FIFO delay behind the data backlog. With the default
topology.executor.receive.buffer.sizeof 32768, a control tuple enqueued behind a full ring waits for up to 32k data tuples to be processed first. For remote control tuples it is even worse: if the ring is full,WorkerState.transferLocalBatchdiverts them into the unboundedoverflowQ, so their delay scales with the entire overflow backlog. -
Silent drops.
Executor.publishFlushTupleusestryPublishDirectand ignores the return value. When the ring is full, i.e. exactly when flushing the producer-side batches matters most, the flush tuple is dropped every interval. -
Blocked timer threads.
setupTicks,scheduleMetricsTickandscheduleUpstreamFeedbackTickall call the blockingreceiveQueue.publish()from the shareduserTimerthread. If one executor's queue is full, the timer thread spins in the backpressure wait strategy and delays timer tasks for every executor in the worker. So a single saturated executor already degrades control signals for its neighbours.
On the proposal itself: I agree with the direction of separating the planes, but I don't think "route everything on a __ stream to the control queue" works as the classification rule. Not all system streams are control plane. The __ack_init / __ack_ack / __ack_fail streams are volume-proportional to the data plane (at least one message per data tuple), and for an acker executor they are the data plane. Routing them into a small queue that is exempt from backpressure would either grow without bound under load or force us to drop ack messages, which breaks at-least-once. The same applies to __metrics (the actual payload stream feeding metrics consumers). Also note that delayed acks throttling the spout via max.spout.pending is intended behaviour, not something we want to bypass.
So the classification should be an explicit whitelist of low-volume, time-driven signals: __flush, __tick, __metrics_tick, __feedback_tick, __feedback. That set should live in one central place (a set plus helper in Constants / Utils) so it cannot drift when new streams are added. Ack streams, __metrics and __system stay on the data path.
One constraint worth stating explicitly, because it rules out some alternatives: control tuples must be consumed on the executor thread. outputCollector.flush(), tick delivery to user code and pending.rotate() all touch single-threaded executor state. A separate control consumer thread is therefore a non-starter; the fix has to happen at the queue level.
Given that, I would suggest a variation of your idea: instead of two JCQueue instances per executor, add a small control lane inside JCQueue. The class already contains two internal queues (recvQueue plus overflowQ) and consumeImpl already does a two-phase drain, so a third small bounded MpscArrayQueue (say 1024 slots) follows the existing pattern and is much less invasive:
- No changes to
executorReceiveQueueMap,taskToExecutorQueue,BackPressureTrackeror the metrics wiring, all of which assume oneJCQueueper executor. consumeImpldrains the control lane first. It is tiny and bounded, so there is no starvation risk for the data plane.- A new
tryPublishControl(obj): non-blocking, no batching, no backpressure participation. On full, drop and count via a new drop metric. Flush and tick tuples are periodic, the next one arrives within milliseconds, so dropping while the consumer is stuck is safe and self-healing. - The control lane is excluded from
getQueueLoad()soLoadAwareShuffleGroupingis unaffected.
Routing changes are needed at the three ingress points: the self-published timer tuples in Executor (which also fixes the blocking timer thread issue as a side effect), ExecutorTransfer.tryTransferLocal for intra-worker traffic, and WorkerState.transferLocalBatch for remote traffic. On the remote path tuples are already deserialized by DeserializingConnectionCallback, so the stream id check is a cheap field access, as you already pointed out.
One semantic change we should document: control tuples will be delivered ahead of co-enqueued data tuples. For everything on the whitelist this is safe, since these are wall-clock signals with no ordering contract against data (tick tuples are documented as best effort anyway). This is also precisely why the ack streams must stay out: they have a per-tuple causal relationship with the data plane.
I would gate the whole thing behind topology.executor.receive.control.queue.enable (default off initially, flip before 3.0.0 GA) plus a topology.executor.receive.control.buffer.size. The steady-state cost when enabled is one poll() on an empty MPSC queue per consume pass plus one set lookup per inbound tuple, both of which should be negligible, but that is what benchmarks are for.
For evaluation I would propose: unit tests on JCQueue for drain priority and drop-on-full behaviour, a throughput regression check with storm-perf (ConstSpoutNullBoltTopo, FileReadWordCountTopo) with the flag on and off, a saturation test (slow consumer plus overdriven spout) measuring timestamped flush and tick delivery latency at p99, and a re-run of JitterAwareGroupingTopology, since the feedback loop from #8593 is the original motivating consumer of bounded control latency.
Hi @rzo1, thanks for the deep dive and the proposal.
Your design is a major improvement over the initial approach.
Embedding the control lane directly within JCQueue is definitely a winning move: it drastically reduces the refactoring blast radius (avoiding changes to queue mapping, backpressure tracking, and metrics wiring) while elegantly solving the three failure modes you highlighted, especially the blocking userTimer thread.
You are also absolutely right about the ackers. Ack traffic is strictly tied to data plane volume (being a function of the graph path size multiplied by the number of tuples). Routing them into the control lane would have introduced a concrete risk of unbounded growth or breaking at-least-once semantics. My initial classification suffered from this bias, and I fully agree with adopting your explicit, restricted whitelist (__flush, __tick, etc.) while keeping everything else on the data path.
I have just opened a draft PR #8892 with the core structure of this solution. I will soon add the benchmarck report. Cheers!
@GGraziadei apologies, haven't had the chance to look over your proposal. Will try to do it ASAP.
Decoupling control and data planes is a strong architectural move for resilience. For repos managing changes to critical infrastructure components, AGENTOWNERS can provide a policy layer defining which automated actors may propose changes to control-plane code and which require human sign-off.