Skip to content

feat: add jitter to worker max runtime#475

Closed
xrompdev wants to merge 42 commits into
dereuromark:masterfrom
Symphosize:symphosize_improvements
Closed

feat: add jitter to worker max runtime#475
xrompdev wants to merge 42 commits into
dereuromark:masterfrom
Symphosize:symphosize_improvements

Conversation

@xrompdev
Copy link
Copy Markdown

Summary

  • Adds configurable jitter (Queue.workermaxruntimejitter) to worker max runtime so workers don't all terminate and restart at the same instant
  • Prevents thundering herd when multiple ECS tasks cycle simultaneously
  • Applied to both runworker and runEcsWorker methods

Test plan

  • Verify workers read Queue.workermaxruntimejitter config value
  • Confirm each worker gets a unique max runtime within the jitter range
  • Observe staggered worker restarts under ECS with multiple tasks

charukiewicz and others added 30 commits May 8, 2015 09:59
changed "hte" to "the"
fix: add additional dupekey to prevent overriding queue
ronmrcdo and others added 12 commits May 8, 2025 04:50
fix: missing additional key on save single connection
…-option

feat: add workermaxmemory option
- Introduced ECS mode in QueueShell for conditional message processing.
- Updated output messages to reflect the current mode (ECS or EC2).
- Added isCompanyForEcsQueue method in QueuedTask to determine ECS eligibility based on company settings.
- Enhanced job handling in QueuedTask to support new job names for ECS-enabled companies.
feat: queue entrypoint for reinit default
Reads Queue.workermaxruntimejitter config and adds a random offset
to each worker's max runtime so they don't all terminate simultaneously.
@dereuromark
Copy link
Copy Markdown
Owner

I guess you are on a very old stage - #476 should solve it for you on the latest.

dereuromark added a commit that referenced this pull request Apr 27, 2026
* Add Queue.workerLifetimeJitter config to stagger worker shutdowns

Each worker picks a random offset in [0, workerLifetimeJitter] at startup
and adds it to its effective lifetime. Prevents thundering-herd restarts
when a fleet of workers (e.g. ECS/Kubernetes tasks) is spawned at the
same instant and would otherwise all exit on the same tick.

Defaults to 0 (no jitter), preserving existing behavior.

Idea and original implementation (against a legacy CakePHP 2.x fork) by
Rommel Penaflor (@xrompdev) in #475; ported to the modern processor.

* Add workerLifetimeJitter to app.example.php

* Align worker lifetime jitter with PHP timeout
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants