我使用的是:
celery==3.1.12
kombu==3.0.19
amqp==1.4.5
芹菜工人启动:
celery worker --without-gossip --without-heartbeat --without-mingle
芹菜套装:
CELERY_ALWAYS_EAGER = False
CELERY_EAGER_PROPAGATES_EXCEPTIONS = True
BROKER_URL = 'amqp://guest:guest@127.0.0.1:5672//'
BROKER_CONNECTION_TIMEOUT = 30
CELERY_RESULT_BACKEND = "amqp"
CELERY_TASK_RESULT_EXPIRES = 18000 # 5 hours.
CELERY_RESULT_PERSISTENT = True
有时我会遇到这样的错误:
Traceback (most recent call last):
File "/usr/local/lib/staging/kava/.envf322d0e225b48a1bb90126f74d73812df3b92994/local/lib/python2.7/site-packages/django/core/handlers/base.py", line 112, in get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/usr/local/lib/staging/kava/.envf322d0e225b48a1bb90126f74d73812df3b92994/local/lib/python2.7/site-packages/newrelic-2.18.1.15/newrelic/hooks/framework_django.py", line 492, in wrapper
return wrapped(*args, **kwargs)
File "/usr/local/lib/staging/kava/.envf322d0e225b48a1bb90126f74d73812df3b92994/local/lib/python2.7/site-packages/django_restapi/resource.py", line 143, in __call__
return self.dispatch(request, self, *args, **kwargs)
File "/usr/local/lib/staging/kava/.envf322d0e225b48a1bb90126f74d73812df3b92994/local/lib/python2.7/site-packages/django_restapi/resource.py", line 76, in dispatch
return target.create(request, *args, **kwargs)
File "./kavyarnya/api/post_deploy.py", line 110, in create
process_commit.delay(project.id, commit, post_deploy_call.id)
File "/usr/local/lib/staging/kava/.envf322d0e225b48a1bb90126f74d73812df3b92994/local/lib/python2.7/site-packages/celery/app/task.py", line 358, in delay
return self.apply_async(args, kwargs)
File "/usr/local/lib/staging/kava/.envf322d0e225b48a1bb90126f74d73812df3b92994/local/lib/python2.7/site-packages/celery/app/task.py", line 474, in apply_async
**options)
File "/usr/local/lib/staging/kava/.envf322d0e225b48a1bb90126f74d73812df3b92994/local/lib/python2.7/site-packages/celery/app/amqp.py", line 249, in publish_task
**kwargs
File "/usr/local/lib/staging/kava/.envf322d0e225b48a1bb90126f74d73812df3b92994/local/lib/python2.7/site-packages/kombu/messaging.py", line 164, in publish
routing_key, mandatory, immediate, exchange, declare)
File "/usr/local/lib/staging/kava/.envf322d0e225b48a1bb90126f74d73812df3b92994/local/lib/python2.7/site-packages/kombu/connection.py", line 470, in _ensured
interval_max)
File "/usr/local/lib/staging/kava/.envf322d0e225b48a1bb90126f74d73812df3b92994/local/lib/python2.7/site-packages/kombu/connection.py", line 396, in ensure_connection
interval_start, interval_step, interval_max, callback)
File "/usr/local/lib/staging/kava/.envf322d0e225b48a1bb90126f74d73812df3b92994/local/lib/python2.7/site-packages/kombu/utils/__init__.py", line 217, in retry_over_time
return fun(*args, **kwargs)
File "/usr/local/lib/staging/kava/.envf322d0e225b48a1bb90126f74d73812df3b92994/local/lib/python2.7/site-packages/kombu/connection.py", line 246, in connect
return self.connection
File "/usr/local/lib/staging/kava/.envf322d0e225b48a1bb90126f74d73812df3b92994/local/lib/python2.7/site-packages/kombu/connection.py", line 761, in connection
self._connection = self._establish_connection()
File "/usr/local/lib/staging/kava/.envf322d0e225b48a1bb90126f74d73812df3b92994/local/lib/python2.7/site-packages/kombu/connection.py", line 720, in _establish_connection
conn = self.transport.establish_connection()
File "/usr/local/lib/staging/kava/.envf322d0e225b48a1bb90126f74d73812df3b92994/local/lib/python2.7/site-packages/kombu/transport/pyamqp.py", line 115, in establish_connection
conn = self.Connection(**opts)
File "/usr/local/lib/staging/kava/.envf322d0e225b48a1bb90126f74d73812df3b92994/local/lib/python2.7/site-packages/amqp/connection.py", line 136, in __init__
self.transport = create_transport(host, connect_timeout, ssl)
File "/usr/local/lib/staging/kava/.envf322d0e225b48a1bb90126f74d73812df3b92994/local/lib/python2.7/site-packages/amqp/transport.py", line 264, in create_transport
return TCPTransport(host, connect_timeout)
File "/usr/local/lib/staging/kava/.envf322d0e225b48a1bb90126f74d73812df3b92994/local/lib/python2.7/site-packages/amqp/transport.py", line 99, in __init__
raise socket.error(last_err)
error: timed out
RabbitMq有取消lt设置。https://www.rabbitmq.com/configure.html
/etc/default/rabbitmq-server : `ulimit -n 16384`
兔子日志:
=WARNING REPORT==== 19-Mar-2016::00:02:17 ===
closing AMQP connection <0.30881.4> (127.0.0.1:26762 -> 127.0.0.1:5672):
connection_closed_abruptly
最大插槽数:
# sysctl -a | grep somax
net.core.somaxconn = 32768
我试图通过以下方式解决这个问题:
- 设置BROKER_HEARTBET=10-我的情况更糟
- 设置BROKER_POOL_LIMIT=无-与当前状态相比没有任何变化
- 将BOKER_CONNECTION_TIMEOUT设置为10、20、30-超时值越大错误越少
我认为增加超时值只是掩盖了真正的问题。这个问题的原因是什么?我该如何解决?感谢
您试图处理的请求率是多少?
您能否分享在您看到超时时运行RabbitMQ的机器上CPU利用率、内存消耗和磁盘IO统计数据的变化?
Rabbit似乎处理连接的速度不够快。
作为一种盲目的猜测,我建议增加Erlang VM I/O线程池的大小(请参阅此处的"Erlang虚拟机I/O线程池"部分https://www.rabbitmq.com/networking.html)
也许可以玩一下兔子的"连接积压"(见同一链接)。
总有一种可能性,你没有足够的资源来处理你收到的请求,所以你可能想扩大你的Rabbit安装。
我重新启动了服务器。它对我有效。
sudo service rabbitmq-server restart