Why Adding Queue Length Made My Bayesian Cluster Scheduler Worse

Leader ●4
calendar_today ago • schedule1 min read
— Originally published at theayush.pages.dev

When I started writing AegisFlow, a zero-dependency Python scheduler for clusters with silent node failures, my first instinct was obvious: use queue depth (queue_len) as distress evidence alongside latency and error rate.

It made inference worse. When I actually inspected env/cluster_env.py, queue_len did not depend on node health or sensor noise at all. It was literally echoing my own scheduler's past dispatches back to me. Feeding a deterministic echo of my own decisions into a Bayesian filter created circular confirmation bias.

Dropping queue_len completely and pulling real signal out of telemetry was where the numbers clicked.

Inferring node health without heuristics

Each node transitions latently between Healthy, Degraded, and Down. Instead of brittle z-score thresholds, agent.py runs an Exact 3-State Bayesian Hidden Markov Model forward filter over heartbeat_ok, latency_ms, error_rate, and per-task duration_remaining progress deltas. Across paired 400-step benchmarks, that reaches 99.58% hidden state accuracy, catching degradation in 0.13 steps and crashes in 0.35 steps with 0.000% false condemnations.

Two math barriers that stopped cascading misses and thrashing

  1. Analytical Triage Gating: Leaving a doomed task pending costs -0.01/step, whereas missing its deadline on a live node slot costs -1.00. Computing completion probability before dispatch keeps uncompletable jobs out of healthy slots, cutting deadline misses by 87% (98.2 -> 13.2, raising on-time completion to 98.3%). Removing triage alone swings ablation reward by +714 points.
  2. Cold-Restart Expected-Value Barrier: In stateful jobs, reassigning a running task resets duration_remaining back to duration_total. Caching duration_total on first sight and requiring target survival gain to strictly beat the lost-progress penalty dropped unnecessary migrations to 0.00 (zero churn), paired with a recovery probation ramp so recovering nodes do not get stampeded immediately.

Written in pure Python stdlib, agent.py runs at 0.64 ms/step (39x under the 25.0 ms budget), passes 31/31 deterministic invariant checks (test_invariants.py), and reaches 96% of the theoretical Oracle ceiling (745.00 vs 750.94).

Benchmark logs and ablation breakdown: https://theayush.pages.dev/projects/aegisflow

Source code: https://github.com/theayushagarwal/AegisFlow

Want more #python & #machinelearning deep dives?

Join 6,155+ developers sharing real benchmarks, code breakdowns, and projects. Free forever.

More Posts

Cisco's Amy Chang: A Model's "Passport" Doesn't Tell You Where It Actually Came From

Tom Smithverified - Aug 27

Sealing My Own Experiment

Ken W. Algerverified - Dec 1

Stop trusting verdicts your policy no longer supports

VEACESLAV - Dec 1

Dashboard Operasional Armada Rental Mobil dengan Python + FastAPI

Masbadar - Mar 12

When One Python Process Fails, You Need to See All of Them

Tom Smithverified - Nov 23
chevron_left
772 Points • 4 Badges
3Posts
0Comments
9Connections
17-year-old Systems & Agent Engineer studying B.Tech CSE at VIT Vellore (Class of 2030). I build dis... Show more

Related Jobs

View all jobs →

Commenters (This Week)

3 comments
1 comment
1 comment

Contribute meaningful comments to climb the leaderboard and earn badges!