storm icon indicating copy to clipboard operation
storm copied to clipboard

Add jitter control loop and `JitterAwareStreamGrouping`

Open GGraziadei opened this issue 6 months ago • 8 comments

What is the purpose of the change

This PR introduces an optional jitter control loop that propagates EWMA jitter measurements to upstream components in a thread-safe manner without imapcting on troughput and latency. This control signal is utilized by JitterAwareStreamGrouping to dynamically route traffic through cluster components based on real-time task jitter.

  • Reduces backpressure: Dynamically steers traffic away from bottlenecked or high-jitter tasks.
  • Improves cluster stability: Minimizes systemic task jitter by balancing the load more intelligently.
  • Boosts overall perf: Optimizes general system throughput and resource utilization.

How was the change tested

  • Unit test
  • Smoke test on dev-cluster
  • Benchmark: storm-perf/JitterAwareGroupingTopology (see results in the comment)

In the context of #8583

GGraziadei avatar May 10 '26 12:05 GGraziadei

@GGraziadei can this one be closed?

reiabreu avatar Jun 01 '26 11:06 reiabreu

Hi @reiabreu

I am currently working asynchronously to propose a code change aimed at stabilizing jitter without impacting throughput or increasing latency.

Unlike the discrete event simulation results, the feedback tuple being evaluated with storm perf is currently degrading performance.

To address this, I am trying to create a feedback tick stream to replace the current ratio-based mechanism.

If performance remains degraded even after this modification, I will post an update and either close the PR or ask for further help in Dev maillist.

GGraziadei avatar Jun 01 '26 18:06 GGraziadei

Hi @reiabreu, I can confirm that the progress on this PR hasn't been lost.

I successfully reproduced these results locally using the storm-perf/FileReadWordCountTopo on a storm development cluster. I am currently refining the solution and will commit the changes to convert this draft into a formal PR soon.

Apologies for the delay—it took some time to verify, but I am confident that using the FeedbackStream tick is the right approach to propagate the control signal without impacting too much on throughput or increasing latency.

Metric No FeedbackTuple (Reference) FeedbackTuple Variance
Elapsed Time (sec) 120 120 0.00%
Workers 2 2 0.00%
Tasks 7 7 0.00%
Executors 7 7 0.00%
Transferred (messages) 35,338,000 34,518,000 -2.32%
Transfer Rate (messages/s) 588,966 575,300 -2.32%
Spout Executors 1 1 0.00%
Spout Transferred (messages) 4,444,000 4,388,000 -1.26%
Spout Acks 4,412,000 4,298,000 -2.58%
Spout Throughput (acks/s) 74,066 73,133 -1.26%
Spout Avg Complete Latency (ms) 457.837 467.308 +2.07%
Spout Max Complete Latency (ms) 457.837 467.308 +2.07%

GGraziadei avatar Jun 06 '26 14:06 GGraziadei

Benchmark

To validate this PR I executed a couple of benchmarks to be sure:

  • No throughput/latency degradation
  • A real advantage to use JitterAwareStreamGrouping in stressed env The benchmark is available in storm-perf/JitterAwareGroupingTopology

I executed the bench with this configuration:

topology.upstream.feedback.freq.secs: 2

I asked an LLM to prepare the attached report, given the benchmark outcome.

Attached to this comment are also the raw data (storm-perf result + Grafana metrics)

(baseline)
------------------------------------------------------------------------------------------------------------------
elapsed (sec),workers,tasks,executors,transferred (messages),transfer rate (messages/s),spout_executors,spout_transferred (messages),spout_acks,spout_throughput (acks/s),spout_avg_complete_latency(ms),spout_max_complete_latency(ms)
------------------------------------------------------------------------------------------------------------------
60,2,10,10,0,0,0,0,0,0,NaN,0.000
120,2,10,10,136220,2270,1,10180,4800,169,29085.146,29085.146
180,2,10,10,74860,1247,1,5060,1640,84,35036.022,35036.022
240,2,10,10,72340,1205,1,4580,1680,76,39128.936,39128.936

Grafana graphs: https://snapshots.raintank.io/dashboard/snapshot/9258h5bMeFXXgdCJ5pcRDZpewUvaGt0P

(feedback control loop)
------------------------------------------------------------------------------------------------------------------
elapsed (sec),workers,tasks,executors,transferred (messages),transfer rate (messages/s),spout_executors,spout_transferred (messages),spout_acks,spout_throughput (acks/s),spout_avg_complete_latency(ms),spout_max_complete_latency(ms)
------------------------------------------------------------------------------------------------------------------
60,2,10,10,0,0,0,0,0,0,NaN,0.000
120,2,10,10,212840,3547,1,15880,11960,264,16683.642,16683.642
180,2,10,10,156920,2615,1,10800,8800,180,16439.405,16683.642
240,2,10,10,42980,716,1,5140,1180,85,15821.700,16683.642

Grafana graphs:
https://snapshots.raintank.io/dashboard/snapshot/t5D0t0X5FDbdUCUJut1bsdvTIIpdWepu

Experimental Results- Impact of FeedbackTuple on Jitter-Aware Stream Grouping.pdf

GGraziadei avatar Jun 12 '26 17:06 GGraziadei

Hi @rzo1,

Thanks for the detailed review! I really appreciated the feedback and learned a lot from it.

You were entirely right about the initial benchmark being skewed (I am sorry for my previous error). It was heavily impacted by a high failure rate due to timeouts (dropping to ~70 tuples/s). Please discard those previous results. I have since applied your suggested fixes to the benchmark setup and properly tuned the max.spout.pending parameter.

Key Updates in this Iteration:

  • Fallback mechanism: The JitterAwareStreamGrouping now implements P2C and properly falls back to LoadAwareStreamGrouping if stats are missing or insufficient to select a candidate task.
  • New baseline: I agree that beating round robin was too low a bar! I have re-run the benchmarks using LoadAwareStreamGrouping as the baseline.
  • Tested scenarios: I evaluated the implementation under varying conditions, including cluster saturation (by tweaking max.spout.pending) as well as simulated network latency and jitter.
  • Overhead analysis: I evaluated the latency and throughput overhead introduced by the feedback tuples using storm-perf/FileReadWordCountTopo. Any potential degradation was too small to be accurately isolated, as the variance falls entirely within the baseline noise floor, making the overhead practically negligible.

I have attached the updated reports and raw data below. Looking forward to your thoughts!

Thanks again!

jitterAwareVSLoadAware.txt

Jitter-Aware vs. Load-Aware Stream Grouping report.pdf

feedbackTupleDegradation.txt

Feedback tuple effects on latency and troughput.pdf

GGraziadei avatar Jun 14 '26 09:06 GGraziadei

Thanks for the thorough turnaround, @GGraziadei — this is a big improvement, and I appreciate you re-running the benchmarks from scratch.

I went back through my previous points and almost everything is resolved:

  • System components are now excluded from the feedback loop (!Utils.isSystemId(componentId) guard)
  • The stream id is a constant (Constants.FEEDBACK_STREAM_ID) instead of a loosely-validated config, which removes both the null-default crash and the stream-overwrite footgun
  • EwmaFeedbackRecord is appended at the end of the Kryo list, so existing registration ids don't shift
  • Routing is now power-of-two-choices with a LoadAwareShuffleGrouping fallback, and the "averaged" doc nit is fixed
  • The two stray imports are gone, the perf claim is out of the example, and the usage/file-open handling is much nicer
  • The security note on netty auth/TLS is a good addition

One thing still open

The feature still silently depends on topology.stats.ewma.enable, which defaults to false. The jitter gauges are only populated when ewmaEnable is true (TaskMetrics complete/process/execute jitter), so with feedback enabled but EWMA left at its default, every EwmaFeedbackRecord is VOID and the grouping just falls back to load-aware forever — no error, no log. Your benchmark topology sets both, which is why it doesn't show up in testing. Could we either fail config validation when topology.upstream.feedback.enable=true and topology.stats.ewma.enable=false, or at minimum log a warning at executor startup? I'd lean toward failing validation since the feature is a no-op without it.

Benchmarks

These now answer my earlier concerns — thank you:

  • The operating point is below the message timeout (acks ≈ transferred now, instead of ~3%), so we're no longer measuring the timeout cliff.
  • The baseline is LoadAwareShuffleGrouping, which is the right comparison.
  • The earlier throughput decay across windows is gone, which lines up with P2C replacing the winner-take-all behavior.
  • The avg/max complete-latency columns are now distinct (max is a proper running max).
  • The overhead run on FileReadWordCountTopo lands entirely within the baseline's own run-to-run spread, which supports "overhead is negligible."

My honest read of the result: at max.spout.pending=500 JitterAware gives a consistent ~5–7% complete-latency reduction over load-aware (with and without the injected network jitter), at comparable throughput. At max.spout.pending=1000 that advantage disappears — JitterAware is roughly equal-to-slightly-worse there. With 2–3 reps and no variance reported, the ~5% delta is close to the rep-to-rep spread, so I'd describe this as "neutral overhead, directionally better latency at moderate load" rather than a throughput win. That's still a reasonable case for the feature as an opt-in, I just want the PR description / docs to frame it that way rather than as a general improvement.

Happy to approve once the EWMA-enable dependency is handled (validation or warning). Nice work iterating on this.

rzo1 avatar Jun 14 '26 17:06 rzo1

Hi @rzo1, good point. I've fixed the configuration issue by implementing a two-phase validation approach. The first phase handles individual field validation, while the second phase checks multi-field combinations. Specifically, the combination validator now ensures that stats are produced whenever the upstream feedback tuple is enabled.

GGraziadei avatar Jun 16 '26 19:06 GGraziadei

CAn you resolve the open onflicts?

rzo1 avatar Jun 18 '26 17:06 rzo1

hello, apologies for taking this long to come back to this one. Let me do a refresher on the whole PR. Thanks

reiabreu avatar Jun 28 '26 15:06 reiabreu

@rzo1 has already done the heavy lifting in this PR, thanks for that. Only very minor stuff left.

CAn you resolve the open onflicts?

@GGraziadei there are still some open conversations. Do you mind resolving them?

  • We should make it clear in the documentation that this new grouping does not guarantee ordering of tuples, since it's a sub-case of Load Aware grouping.
  • My honest read of the result: at max.spout.pending=500 JitterAware gives a consistent ~5–7% complete-latency reduction over load-aware (with and without the injected network jitter), at comparable throughput. At max.spout.pending=1000 that advantage disappears — JitterAware is roughly equal-to-slightly-worse there. With 2–3 reps and no variance reported, the ~5% delta is close to the rep-to-rep spread, so I'd describe this as "neutral overhead, directionally better latency at moderate load" rather than a throughput win. That's still a reasonable case for the feature as an opt-in, I just want the PR description / docs to frame it that way rather than as a general improvement.

    • We should also point out what @rzo1 commented above

Thanks for the great PR. Touches on a lot of complex concepts

reiabreu avatar Jun 28 '26 18:06 reiabreu

@GGraziadei feel free to merge it. Outstanding issues are non-blocker and you can fix them later.

reiabreu avatar Jun 28 '26 18:06 reiabreu

Just one thing that I only noticed right now: FEEDBACK_TICK_STREAM_ID goes through the data receive queue of every downstream task. Under load, this signal will get queued up and the jitter signals from the task to the upstream ones will get delayed, preventing the mechanism from working. This problem already existed prior to your PR: scheduleMetricsTick does the same. Can we open an issue as a follow up to address this? Unless @rzo1 you think it's a blocker

reiabreu avatar Jun 28 '26 18:06 reiabreu

Just one thing that I only noticed right now: FEEDBACK_TICK_STREAM_ID goes through the data receive queue of every downstream task. Under load, this signal will get queued up and the jitter signals from the task to the upstream ones will get delayed, preventing the mechanism from working. This problem already existed prior to your PR: scheduleMetricsTick does the same. Can we open an issue as a follow up to address this? Unless @rzo1 you think it's a blocker

I am fine with both approaches as long as we can get it efixed before we go 3.0.0 GA maybe. @GGraziadei wdyt?

rzo1 avatar Jun 28 '26 18:06 rzo1

Thank you both for the review and the insightful discussion!

First of all, my apologies for not replying explicitly earlier, I have already merged the main branch and resolved the open conflicts.

Tomorrow, I will update the documentation to improve the presentation of the benchmark results, framing them in a more neutral way as suggested (highlighting the directional latency improvement under moderate load and clarifying that tuple ordering is not guaranteed).

Regarding the mixing of the control plane and data plane on the same queues: I completely agree. Under heavy load, this buffering delay will inevitably make the jitter/feedback mechanism less responsive.

Tomorrow, I will open a dedicated follow-up issue to address this. My initial thought is that we could resolve this by decoupling the queues and separating system streams traffic, but it will definitely be useful to discuss with and evaluate all possible options within that ad-hoc issue.

Thanks again for catching this!

GGraziadei avatar Jun 28 '26 22:06 GGraziadei

Thank you both for the review and the insights! I have updated the Javadoc to frame the stream grouping behavior and benchmark results in a more neutral way. Regarding @reiabreu point about FEEDBACK_TICK_STREAM_ID, this actually extends to all control plane traffic, such as metrics ticks and heartbeats. The issue is more generic and definitely non-blocking for this PR. To address this, I have opened a follow-up issue here: #8816

I’ve already included an initial solution with its pros and cons in the description, but I will also start a thread on the dev@ mailing list shortly to get feedback from the community, maybe someone has an even better approach!

Merging this now. Thanks again!

GGraziadei avatar Jun 29 '26 18:06 GGraziadei