[英]Celery with Redis broker in Django: tasks successfully execute, but too many persistent Redis keys and connections remain
Our Python server (Django 1.11.17) uses Celery 4.2.1 with Redis as the broker (the pip redis package we're using is 3.0.1). 我们的Python服务器(Django 1.11.17)使用带有Redis的Celery 4.2.1作为代理(我们使用的pip redis软件包是3.0.1)。 The Django app is deployed to Heroku, and the Celery broker was set up using Heroku's Redis Cloud add-on.
Django应用程序已部署到Heroku,而Celery经纪人是使用Heroku的Redis Cloud插件设置的。
The Celery tasks we have should definitely have completed within a minute (median completion time is ~100 ms), but we're seeing that Redis keys and connections are persisting for much, much longer than that (up to 24 hours). 我们已经完成的Celery任务肯定应该在一分钟内完成(中值完成时间约为100毫秒),但是我们发现Redis密钥和连接的持久性要长得多(长达24小时)。 Otherwise, tasks are being executed correctly.
否则,任务将正确执行。
What can be happening that's causing these persisting keys and connections in our Redis broker? 会发生什么,导致这些Redis代理中的持久键和连接持久化? How can we clear them when Celery tasks conclude?
当芹菜任务完成时,我们如何清除它们?
Here's a Redis Labs screenshot of this happening (all tasks should have completed, so we'd expect zero keys and zero connections): 这是Redis Labs发生的这种情况的屏幕截图(所有任务都应该已经完成,因此我们期望零键和零连接):
Resolved my own question: if the CELERY_IGNORE_RESULT
config variable is set to True
(which I'm able to do because I don't use any return values from my tasks), then the keys and connections are back under control. 解决了我自己的问题:如果将
CELERY_IGNORE_RESULT
配置变量设置为True
(我能够执行此操作,因为我不使用任务中的任何返回值),那么键和连接将重新受到控制。
Source: Celery project documentation 资料来源: 芹菜项目文档
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.