You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Subscribe too much celery-task-meta using Redis backend #3808
With redis as backend, using redis-cli monitor command, when adding a task into celery, it actually uses the SUBSCRIBE command in redis. Like "SUBSCRIBE" "celery-task-meta-cb1792d7-9e9d-43d9-b374-3a8b15c97790"
However, I found a strange thing that after adding an amount of tasks, redis will sometimes block and cause time out. It's caused by the a.py process. redis-cli monitor shows that a.py process is trying to subscribe a very huge amount of celery-task-meta, like "SUBSCRIBE" "celery-task-meta-f6347dbe-c91b-4c95-bcbd-3dfefbcb2f46" "celery-task-meta-83f7be2a-2906-4e34-965a-47cec416d6df" "celery-task-meta-3c3e8eff-711d-4d44-bbd4-d36adea85ecd" "celery-task-meta-22492fff-2b7a-4e69-83de-71191e66861c" "celery-task-meta-1ae1f78a-ad78-47eb-a422-25d42a33fd83" "celery-task-meta-ed041055-f2cf-4f60-a531-dbc764dff5c4" ......
I wander why it behaves like this, is it a bug or a normal act?
Reacted by Tomer Chachamu, Jerry, Udayakumar Rayala, Mike Lissner, Yutao, Matt Dodge, Michael Chirico and Nate Yoder
@gugu I am curious that why does Celery do so. For example, when we use Celery in web for sending email, which I think it's a very common sense, the process which adds the task into the Celery does not exactly care about the result. So in Redis, maybe it should use PUBLISH instead of SUBSCRIBE?
I notice that after SUBSCRIBE performance, there will always be a LPUSH followed, I guess it's used to avoid multiple workers achieve the same task.
Oops, I'm now very curious about how Celery works. Do you have any idea or blog or something else?
celery:4.0.2 python:3.5.2 redis:3.2.1
os: CentOS release 6.7 (Final)
I also meet this problem. When I run celery some hours,It while be subscribe ten of thousands celery-task-meta-xxx, make redis very slow.Sometimes it made task.get() raise redis.exceptions.ResponseError: unknown command 'celery-task-meta-xxxx' error.
I still notice a SUBSCRIBE command with a growing list of celery-task-meta on master (using redis-cli monitor), when using RabbitMQ as broker and Redis as backend. The command is not monotonically growing, so sometimes tasks disappear again from the list (usually from the tail), but the trend is for the command to keep growing and for the tasks at the beginning of the list to stabilize.
The sheer size of this command seems to eventually cause the ResponseError reported in #3808 (comment). So it seems this issue is still present.
@VictorLeP there are some channel subscriptions opened by the worker (in case of chord or other workflows using results) and also by the client that waits for the task result. So, depending on the usage, and how many tasks you have simultaneously being executed, you may see a growing number of channels. Are you certain that this appears on master?
@georgepsarakis Yes, I tested it with the latest master version (also tested with kombu's master version now). I use 'normal' tasks (sent using app.send_task), of which there is a constant stream to the workers, but I see in the worker logs that the tasks that appear in the growing subscription list have succeeded. In any case, there are appropriate timeouts and the task ID remain in the subscription list longer than the timeout.
Same issue. In my case, just a few calls like r = somefunc.delay(), produces millions of channels with about 33G memory used after serveral months, my server is trembling 😢, must we wait for v5.0?
We are facing the same issue. Creating new tasks becomes really slow and when I checked the SLOWLOG, we found subscribe calls with huge number of channels are very slow. It looked like these subscribe calls are made from kombu and I get the big subscribe calls after the queue size reaches around ~300k. It might be because of Redis having a limitation on the number of subscribed channels.
Surprisingly, this happens even for tasks with ignore_result=True and not running a celery worker. I expected no subscribe calls made in this scenario. Then I found this code. I wonder if this reason for the subscribe calls. Can someone with more context about this help confirm?
Activity
gugu commentedon Feb 6, 2017
It is how celery 4 work – instead of get/set it subscribes on changes for tasks in chord, as fas as I know
UPD: subscribe is not a problem. But no "UNSUBSCRIBE" is a problem. I created bug #3812
memwey commentedon Feb 7, 2017
@gugu I am curious that why does Celery do so. For example, when we use Celery in web for sending email, which I think it's a very common sense, the process which adds the task into the Celery does not exactly care about the result. So in Redis, maybe it should use
PUBLISHinstead ofSUBSCRIBE?I notice that after
SUBSCRIBEperformance, there will always be aLPUSHfollowed, I guess it's used to avoid multiple workers achieve the same task.Oops, I'm now very curious about how Celery works. Do you have any idea or blog or something else?
shidenggui commentedon Mar 24, 2017
celery:4.0.2 python:3.5.2 redis:3.2.1
os: CentOS release 6.7 (Final)
I also meet this problem. When I run celery some hours,It while be subscribe ten of thousands
celery-task-meta-xxx, make redis very slow.Sometimes it made task.get() raiseredis.exceptions.ResponseError: unknown command 'celery-task-meta-xxxx'error.auvipy commentedon Jan 17, 2018
try the new release and docs and report the issue again
wsYdd commentedon Jan 23, 2018
This new release is v4.2?
When do you plan to release this version?
auvipy commentedon Jan 23, 2018
I will reopen if this can be reproduced in master. check the milestone only 1 documentation blocker remain
VictorLeP commentedon Jan 29, 2018
I still notice a
SUBSCRIBEcommand with a growing list ofcelery-task-metaon master (usingredis-cli monitor), when using RabbitMQ as broker and Redis as backend. The command is not monotonically growing, so sometimes tasks disappear again from the list (usually from the tail), but the trend is for the command to keep growing and for the tasks at the beginning of the list to stabilize.The sheer size of this command seems to eventually cause the
ResponseErrorreported in #3808 (comment). So it seems this issue is still present.Report:
georgepsarakis commentedon Feb 10, 2018
@VictorLeP there are some channel subscriptions opened by the worker (in case of chord or other workflows using results) and also by the client that waits for the task result. So, depending on the usage, and how many tasks you have simultaneously being executed, you may see a growing number of channels. Are you certain that this appears on
master?VictorLeP commentedon Feb 13, 2018
@georgepsarakis Yes, I tested it with the latest
masterversion (also tested with kombu'smasterversion now). I use 'normal' tasks (sent usingapp.send_task), of which there is a constant stream to the workers, but I see in the worker logs that the tasks that appear in the growing subscription list have succeeded. In any case, there are appropriate timeouts and the task ID remain in the subscription list longer than the timeout.jetz commentedon Feb 26, 2018
Same issue. In my case, just a few calls like
r = somefunc.delay(), produces millions of channels with about 33G memory used after serveral months, my server is trembling 😢, must we wait for v5.0?uday-rayala commentedon Mar 18, 2018
We are facing the same issue. Creating new tasks becomes really slow and when I checked the SLOWLOG, we found subscribe calls with huge number of channels are very slow. It looked like these subscribe calls are made from kombu and I get the big subscribe calls after the queue size reaches around ~300k. It might be because of Redis having a limitation on the number of subscribed channels.
Surprisingly, this happens even for tasks with
ignore_result=Trueand not running a celery worker. I expected no subscribe calls made in this scenario. Then I found this code. I wonder if this reason for the subscribe calls. Can someone with more context about this help confirm?44 remaining items
Mr-Slow commentedon Apr 25, 2023
Have this fixed?
WeipingGuo commentedon Apr 25, 2023
Same question, we are upgrading from celery 4 to 5, hope this is fixed.
We see the same issue for redis==3.5.3 and celery==4.4.0
gaozhidf commentedon May 30, 2023
same question, redis==3.3.11 and celery==4.3.0
gaozhidf commentedon May 30, 2023
@WeipingGuo do you fix this after upgrading to celery 5?
WeipingGuo commentedon May 30, 2023
@gaozhidf We have not completed the full upgrade yet, fingers crossed