我正在使用:
celery==3.1.12
kombu==3.0.19
amqp==1.4.5
celery 工这才开腔:
celery worker --without-gossip --without-heartbeat --without-mingle
celery 盘:
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有默认设置。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
我尝试通过以下方式解决此问题:
1.设置BROKER_HEARTBEAT = 10 -我遇到了更糟糕的情况
1.设置BROKER_POOL_LIMIT =无-相对于当前状态无任何更改
1.将BOKER_CONNECTION_TIMEOUT设置为10、20、30 -超时值越大,错误越少
我认为增加超时值只是隐藏了真正的问题。这个问题的原因是什么?我该如何解决它?谢谢
2条答案
按热度按时间ifmq2ha21#
您尝试处理的请求数是多少?
您能否分享一下在运行RabbitMQ的机器上,当您看到超时时,CPU利用率、内存消耗、磁盘IO统计数据会发生什么变化?
看来Rabbit处理连接的速度不够快
作为一个盲目的猜测,我建议增加Erlang VM I/O线程池的大小(请参见此处的“Erlang VM I/O线程池”部分https://www.rabbitmq.com/networking.html)
也许可以玩一下兔子的“连接积压”(见同一链接)。
您总是有可能没有足够的资源来满足您所收到的请求的数量,因此您可能需要扩展您的Rabbit安装。
okxuctiv2#
我重新启动了服务器。它为我工作。