芹菜是否正确遵循我的速率限制?

Is celery following my rate limit properly?

我在 Celery 中有一个限速任务,但 Flower 中显示的结果让它看起来好像正在立即处理一堆任务,然后遵守限速。为什么会这样?我需要做些什么来确保它从一开始就遵守速率限制吗?

@shared_task(rate_limit="4/m")
    def my_task(a,b):
        ...

...

my_task.apply_async((x, y,),)

您是否有不止一名工人在消费 my_task?如果是这样,您的速率限制将不会生效,因为 celery 速率限制是 per worker (docs). To get around this you'll need to route my_task to a queue that has only one worker consuming from it. See routing docs.