Skip to content

Commit 30e476b

Browse files
committed
feat(supervisor): wire scale-up freeze and resume ramp
Pass shouldPauseScaling (monitor.isEngaged) into the consumer pool so scale-up freezes while hard-engaged, and feed TRIGGER_DEQUEUE_BACKPRESSURE_RAMP_MS into the monitor's post-release ramp. Off by default.
1 parent 8190215 commit 30e476b

2 files changed

Lines changed: 7 additions & 0 deletions

File tree

apps/supervisor/src/env.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ const Env = z
5454
TRIGGER_DEQUEUE_BACKPRESSURE_ENABLED: BoolEnv.default(false),
5555
TRIGGER_DEQUEUE_BACKPRESSURE_REDIS_KEY: z.string().default("engine:dequeue:backpressure"),
5656
TRIGGER_DEQUEUE_BACKPRESSURE_REFRESH_MS: z.coerce.number().int().positive().default(1000),
57+
TRIGGER_DEQUEUE_BACKPRESSURE_RAMP_MS: z.coerce.number().int().min(0).default(30_000), // Resume ramp window after release; 0 = instant resume
58+
5759
TRIGGER_DEQUEUE_BACKPRESSURE_MAX_VERDICT_AGE_MS: z.coerce
5860
.number()
5961
.int()

apps/supervisor/src/index.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,12 +208,14 @@ class ManagedSupervisor {
208208
),
209209
refreshIntervalMs: env.TRIGGER_DEQUEUE_BACKPRESSURE_REFRESH_MS,
210210
maxVerdictAgeMs: env.TRIGGER_DEQUEUE_BACKPRESSURE_MAX_VERDICT_AGE_MS,
211+
rampMs: env.TRIGGER_DEQUEUE_BACKPRESSURE_RAMP_MS,
211212
});
212213

213214
this.logger.log("🛑 Dequeue backpressure enabled", {
214215
key: env.TRIGGER_DEQUEUE_BACKPRESSURE_REDIS_KEY,
215216
refreshIntervalMs: env.TRIGGER_DEQUEUE_BACKPRESSURE_REFRESH_MS,
216217
maxVerdictAgeMs: env.TRIGGER_DEQUEUE_BACKPRESSURE_MAX_VERDICT_AGE_MS,
218+
rampMs: env.TRIGGER_DEQUEUE_BACKPRESSURE_RAMP_MS,
217219
});
218220
}
219221

@@ -237,6 +239,9 @@ class ManagedSupervisor {
237239
ewmaAlpha: env.TRIGGER_DEQUEUE_SCALING_EWMA_ALPHA,
238240
batchWindowMs: env.TRIGGER_DEQUEUE_SCALING_BATCH_WINDOW_MS,
239241
dampingFactor: env.TRIGGER_DEQUEUE_SCALING_DAMPING_FACTOR,
242+
// Freeze scale-up while backpressure is hard-engaged (not during the resume
243+
// ramp). Undefined when backpressure is disabled → no effect on scaling.
244+
shouldPauseScaling: () => this.backpressureMonitor?.isEngaged() ?? false,
240245
},
241246
runNotificationsEnabled: env.TRIGGER_WORKLOAD_API_ENABLED,
242247
heartbeatIntervalSeconds: env.TRIGGER_WORKER_HEARTBEAT_INTERVAL_SECONDS,

0 commit comments

Comments
 (0)