Skip to content

Slightly decrease importance of all cron tasks #26073

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

Closed
wants to merge 4 commits into from

Conversation

fredden
Copy link
Member

@fredden fredden commented Dec 16, 2019

Description

Set process priority for scheduled tasks & queue consumers to be less important than website visitors.

When the scheduled processes are run on a separate host to website visitors, this change will have little effect. When the scheduled processes are run on the same host as is used by website visitors, this change makes it less likely that a website would become unavailable when scheduled tasks (such as indexers, queue consumers, or other scheduled tasks) run an intensive process.

Due to the way that queue consumers are initialised, they will end up with a nice level of double this value*, while standard scheduled tasks (eg, bulk_cleanup, sales_send_order_emails) will be run with a nice level of this value only. This actually means that queue consumers (such as exportProcessor) will be even less important than other scheduled tasks.

* The parent process will get this value, and pass the same to its child, which hits the same code-path and then increases its nice level by the same amount again.

Fixed Issues

  1. This does not fix, but may help with: Magento 2.3.3 Cronjob use too much CPU source #25634: Magento 2.3.3 Cronjob use too much CPU source

Manual testing scenarios

  1. Run Magento scheduled tasks via cron or by manually running php bin/magento cron:run
  2. Observe process nice levels with a tool such as ps or htop on Unix. (I'm not sure what equivalent tools are available on Windows.)

Questions or comments

I do not know how to write a unit test for this change.

Contribution checklist

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All new or changed code is covered with unit/integration tests (if applicable)
  • All automated tests passed successfully (all builds are green)

@m2-assistant
Copy link

m2-assistant bot commented Dec 16, 2019

Hi @fredden. Thank you for your contribution
Here is some useful tips how you can test your changes using Magento test environment.
Add the comment under your pull request to deploy test or vanilla Magento instance:

  • @magento give me test instance - deploy test instance based on PR changes
  • @magento give me 2.4-develop instance - deploy vanilla Magento instance

For more details, please, review the Magento Contributor Guide documentation.

@magento-engcom-team magento-engcom-team added Partner: Fisheye partners-contribution Pull Request is created by Magento Partner labels Dec 16, 2019
@slavvka
Copy link
Member

slavvka commented Jan 29, 2020

Hey @fredden Thank you for the contribution but such adjustments should be applied on the level of server configuration. Magento code shouldn't control it. I am closing the PR.

@slavvka slavvka closed this Jan 29, 2020
@m2-assistant
Copy link

m2-assistant bot commented Jan 29, 2020

Hi @fredden, thank you for your contribution!
Please, complete Contribution Survey, it will take less than a minute.
Your feedback will help us to improve contribution process.

@fredden fredden deleted the nice-cron branch February 1, 2020 23:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Cron Partner: Fisheye partners-contribution Pull Request is created by Magento Partner
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants