跳过正文

Python

生产环境 Agent 实践:为什么我们从 Celery 迁移到 Temporal

2026 年 4 月,我们把 seo-project 的任务队列从 Celery 全面迁移到了 Temporal。删除的依赖只有一个(celery),新增的核心代码有 11 个文件(src/infrastructure/temporal/),容器从 api/worker/beat 变成了 api/temporal_worker_blue/green(蓝绿部署)。 这件事做完后,最常被问到的问题是:为什么不用 Celery?已经能跑的东西换它干什么? 这篇文章就是答案。它不来自文档对比,来自生产环境跑 Agent 流水线时逐条撞上的坑。 Celery 能做的事,为什么在 Agent 场景里开始不够用 # 先说清楚一个基本判断:Celery 是好工具。对于"发封邮件、生成一张缩略图、推送一条通知"这类标准异步任务,它完全够用,工业界跑了十几年。 但我们跑的负载和这不一样: 1 2 3 4 5 6 一个 Run 包含 N 条 longtail 每条 longtail 跑 A → B → C → D 四个 Agent 阶段 每个阶段调一次或多次 AI API 总耗时任意一条都在 60-180 秒区间 每一步的中间结果需要持久化 任何一步失败需要知道"停在哪、为什么、能不能只重试这一步" 这是有状态的、长时的、多阶段的业务流程。任务队列和业务流程引擎之间的分界线,就在这里。

Why We Moved from Celery to Temporal for Production Agent Pipelines

In April 2026, we migrated seo-project’s task queue from Celery to Temporal. We dropped exactly one dependency (celery), wrote 11 new files (src/infrastructure/temporal/), and renamed our containers from api/worker/beat to api/temporal_worker_blue/green with blue-green deployment. The most common question afterward: why not just keep using Celery? If it’s already running, what’s the point? This article is the answer. It doesn’t come from documentation comparisons. It comes from production bugs we hit running Agent pipelines at scale.