Festival day
Exam results come out and 100 jobs a second pour into your SQS queue for ten ticks. Workers scale on backlog per worker, but new ones take time to boot, and every worker-tick costs money. Instead of guessing, simulate: run each candidate configuration through the rush and pick the cheapest that keeps the backlog under your target.
One tick at a time
- Jobs arrive and join the backlog.
- Workers that finished booting start working.
- Each active worker clears perWorker jobs.
- Desired workers = ceil(backlog ÷ targetBacklog), clamped to min…max: launch (they boot for startupDelay ticks) or stop active ones.
- Pay for every active and booting worker.
const spike = (t) => (t >= 5 && t < 15 ? 100 : 5); // a 10-tick rush