Skip to content
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

[8.x] Ability to slow the workers down #36521

Merged
merged 1 commit into from
Mar 9, 2021
Merged

Conversation

themsaid
Copy link
Member

@themsaid themsaid commented Mar 9, 2021

php artisan queue:work --rest=0.5

Using the rest option, the worker will sleep after processing each job. This will slow down job processing.

This was requested by @fideloper a few months back and I kept getting similar requests regarding it for several people so I thought I'd propose it.

/**
* The number of seconds to rest between jobs.
*
* @var int
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your example is float?

Copy link
Member Author

@themsaid themsaid Mar 9, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

similar to sleep. maybe in another commit we change both to float|int.

@paras-malhotra
Copy link
Contributor

Is the main benefit here for the SQS driver to reduce API calls? Or perhaps even have jobs accumulate resources to process like laravel/ideas#2460?

@fideloper
Copy link
Contributor

SQS api calls are one benefit (altho a similar PR could be made to use the SQS option that keeps a connection open to up to 30 seconds or so (IIRC) to wait further jobs - "long polling" of sorts.

My specific use case was wanting to throttle email sends through systems our customers use that throttle email sends over time.

@themsaid
Copy link
Member Author

themsaid commented Mar 9, 2021

@paras-malhotra another benifit that was requested is to be able to control the rate of job processing in a limited-resources server where a burst of jops would cause the server to crash. Slowing down the processing allows the server to recover between jobs and do other things (like serve HTTP requests).

@taylorotwell taylorotwell merged commit 55a1407 into laravel:8.x Mar 9, 2021
This was referenced Mar 10, 2021
@dmyers
Copy link
Contributor

dmyers commented May 12, 2021

This was a breaking change for my application which uses Laravel Horizon.

We started seeing these errors when running php artisan horizon:

  The "rest" option does not exist.
  The "rest" option does not exist.
  The "rest" option does not exist.
  The "rest" option does not exist.

Should this be a part of upgrade notes or the changeling in some way to inform people to upgrade Laravel Horizon which includes this change? https://github.com/laravel/horizon/pull/992/files

@driesvints
Copy link
Member

@dmyers what's your use case for updating the framework and not horizon?

@denniseilander
Copy link
Contributor

@driesvints I had the same issue. It was caused by our auto security checker which bumped Laravel from v8.24.0 to v8.43.0, so laravel/horizon kept its current version.

@driesvints
Copy link
Member

@denniseilander please update horizon as well.

@denniseilander
Copy link
Contributor

@driesvints yes, from now on I'll update horizon when laravel/framework is updated. Thanks!

@35grain
Copy link

35grain commented May 8, 2023

Why isn't this useful feature included in the documentation?

@denniseilander
Copy link
Contributor

@35grain Not everything is documented, as it is impossible to do IMO.
But feel free to open a PR to include it in the docs since it will be useful :)

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.

None yet

9 participants