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

[POC] Requeue tasks after ETA is met #7305

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

emarbo
Copy link

@emarbo emarbo commented Feb 17, 2022

Fixes #6500

This PR is just a proof of concept as requested here. It is far away to be something complete but it illustrates the idea and addresses the problem.

Description

Workers using --prefetch-multiplier 1 and acks_late should never reserve more tasks than their concurrency level. In other words, they should reserve 1 task for every child worker.

However, when a worker receives an ETA task, it holds the task in memory (unacknowledged) and increases the QoS to allow RabbitMQ to send a new task. So, the QoS of workers is:

worker_qos = prefetch_multiplier * concurrency + tasks_with_future_eta

When the ETA is met, the worker decreases the QoS but still holds the task until one child worker gets idle. This PR attempts to solve the problem by just queueing the task back to RabbitMQ at the same position it was so that other idle consumers can process it immediately.

POC

The eta_poc example has the instructions to test the behaviour and to compare it with the current implementation.

@emarbo emarbo changed the title Requeue tasks after ETA is met - POC [POC] Requeue tasks after ETA is met Feb 17, 2022
@lgtm-com
Copy link

lgtm-com bot commented Feb 17, 2022

This pull request introduces 1 alert when merging e66b7fb into 239ed3c - view on LGTM.com

new alerts:

  • 1 for Module is imported with 'import' and 'import from'

Copy link
Member

@auvipy auvipy left a comment

Choose a reason for hiding this comment

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

can you resume the effort to include it in celery 5.4.0 please?

@auvipy auvipy added this to the 5.4 milestone Nov 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add a configuration option to disable prefetch completely
3 participants