Skip to content

Speed up Celery task publishing with Redis pipelines#70455

Draft
shivaam wants to merge 1 commit into
apache:mainfrom
shivaam:codex/airflow-investigate-issue-8854
Draft

Speed up Celery task publishing with Redis pipelines#70455
shivaam wants to merge 1 commit into
apache:mainfrom
shivaam:codex/airflow-investigate-issue-8854

Conversation

@shivaam

@shivaam shivaam commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

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 mirrors
Kombu's private Redis transport methods, so a focused contract test will fail
if a future Kombu update changes that integration point.

Local validation:

  • Celery executor unit module: 74 passed, 6 skipped.
  • Linux multiprocessing regression: passed 250 repeated dispatch cycles.
  • PostgreSQL/Celery integration suite: 10 passed with real Redis and RabbitMQ
    brokers and Celery workers.
  • Real daemon load: scheduler, API server, DAG processor, triggerer, PostgreSQL,
    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.
  • Changed source files pass mypy; regular prek checks pass. The
    provider-wide manual mypy hook was terminated by the local Docker resource
    limit (exit 137/143).

closes: #8854


Was generative AI tooling used to co-author this PR?
  • Yes — Codex (GPT-5)

Generated-by: Codex (GPT-5) following the guidelines


Drafted-by: Codex (GPT-5) (no human review before posting)

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.
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.

Send task to queue in bulk - Celery Executor

1 participant