Speed up Celery task publishing with Redis pipelines#70455
Draft
shivaam wants to merge 1 commit into
Draft
Conversation
CeleryExecutor pays one Redis network round trip per task today, which makes scheduler publication latency grow with batch size and broker latency. Large scheduler batches can therefore spend much longer sending work than selecting it. Keep the existing path available because the optimized Redis integration depends on Kombu transport internals and deployments may prefer compatibility over throughput.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
CeleryExecutor currently publishes each task to Redis in a separate network
round trip. This makes publication time grow with both the number of scheduled
tasks and broker latency.
This change lets Celery and Kombu prepare each task message normally, then
buffers the final Redis queue writes in a non-transactional pipeline and
flushes them together. Callback workloads and non-Redis brokers keep the
existing publication path.
Redis pipelining is enabled by default and can be disabled with
[celery] redis_pipelined_publish_enabled = False. The implementation mirrorsKombu's private Redis transport methods, so a focused contract test will fail
if a future Kombu update changes that integration point.
Local validation:
brokers and Celery workers.
Redis, and a four-process Celery worker completed 1,000/1,000 Bash tasks and
four/four DAG runs successfully. Redis recorded exactly 1,000 queue writes
and drained to zero.
mypy; regularprekchecks pass. Theprovider-wide manual
mypyhook was terminated by the local Docker resourcelimit (exit 137/143).
closes: #8854
Was generative AI tooling used to co-author this PR?
Generated-by: Codex (GPT-5) following the guidelines
Drafted-by: Codex (GPT-5) (no human review before posting)