如何强制celery任务由单个docker容器处理?

发布于 2025-01-19 11:04:32 字数 329 浏览 3 评论 0原文

我目前正在运行芹菜和弦任务,其中包含许多小组任务。小组任务在磁盘上写入一些文件,然后将文件名传递给Chord回调任务,该任务处理这些文件以创建最终结果。所有这些都是在通过烧瓶API访问的Docker容器中运行的。该系统正常工作,直到只有1个Docker容器运行芹菜为止。

一旦我想通过添加另一个Docker容器来扩展芹菜,就开始破裂,因为组任务是在多个容器上分布的,并且文件无法用于Chord回调任务。

我如何确保此完整的任务运行在一个容器上,如果处理第一个任务时,它将进入闲置的芹菜容器并在那里运行?

添加共享卷对我的用例不起作用,因为我想向此添加自动尺度,这将在不同的机器/实例上强制执行容器。

I am currently running a celery chord task with a bunch of group tasks within it. The group tasks write some files on the disk and pass on the filenames to the chord callback task which processes these files to create the final result. All of this is running inside a docker container which is accessed via flask API. This system works fine till the time there is only 1 docker container running celery.



As soon as I want to scale celery up by adding another docker container, things start breaking because the group tasks are distributed across multiple containers and the files are unavailable to the chord callback task.



How can I ensure that this complete task run on a single container and if another task comes in while the first one is being processed, it goes to the idle celery container and runs over there?



Adding a shared volume will not work for my use-case since I want to add auto-scaling to this which will enforce the containers to be on different machines/instances.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文