Skip to content

Cooldown Worker Only on Failed Processes #1566

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 16, 2025

Conversation

dbpolito
Copy link
Contributor

@dbpolito dbpolito commented Jun 13, 2025

Problem

Currently, Horizon adds a 1-minute cooldown if a worker dies in less than 1 second. While this is a sensible default to prevent rapid restarts, it causes issues in some scenarios.

For example, I have a job that runs in under 1 second but exceeds the memory limit of the worker (e.g., >128MB). This causes the worker to be gracefully stopped (exit code 0) and replaced. However, because the cooldown logic treats all quick exits the same, it enforces a 1-minute delay before restarting the worker.

As a result, even with autoscaling set to 10 workers, I’m only processing 10 jobs per minute, one per worker, because each is subject to the cooldown.

Solution

This PR updates the cooldown logic to only apply when a worker fails (i.e., crashes or exits with a non-zero code). If the worker exits gracefully (exit code 0), no cooldown is applied.

This change ensures that autoscaling and memory limits can work together effectively without unintentionally throttling throughput.

Related

This issue might be related to the discussion in this comment on PR #1473.

@taylorotwell taylorotwell merged commit 50057bc into laravel:5.x Jun 16, 2025
16 checks passed
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.

2 participants