我正在部署(守护)芹菜。以下是我的芹菜文件。
CELERYD_NODES="worker1 worker2 worker3 worker4"
CELERY_BIN="/usr/local/bin/celery"
CELERY_APP="proj:app"
CELERYD_CHDIR="/path/to/proj/"
CELERYD_OPTS="-n %N@%h --config=proj.celeryconfig -l DEBUG --without-heartbeat"
CELERYD_LOG_FILE="/var/log/celery/%N.log"
CELERYD_PID_FILE="/var/run/celery/%N.pid"
CELERYD_USER="celery"
CELERYD_GROUP="celery"
CELERY_CREATE_DIRS=1
当我开始芹菜时,它会产生20个过程。为什么以及如何?我的服务器有4个CPU。
触发以下命令
ps aux|grep 'celery worker'
以下是输出。
gfile=/var/log/celery/worker1.log --pidfile=/var/run/celery/worker1.pid --hostname=worker1@worker1@worker1@worker1@%h
celery 26652 5.7 0.8 270340 66892 ? S 18:41 0:02 /usr/bin/python -m celery worker --without-heartbeat -l DEBUG --config=c26_message.celeryconfig --loglevel=INFO --logfile=/var/log/celery/worker2.log --pidfile=/var/run/celery/worker2.pid --hostname=worker2@worker2@worker2@worker2@%h
celery 26662 1.0 0.7 860128 59364 ? Sl 18:41 0:00 /usr/bin/python -m celery worker --without-heartbeat -l DEBUG --config=c26_message.celeryconfig --loglevel=INFO --logfile=/var/log/celery/worker1.log --pidfile=/var/run/celery/worker1.pid --hostname=worker1@worker1@worker1@worker1@%h
celery 26663 1.1 0.7 565456 59584 ? S 18:41 0:00 /usr/bin/python -m celery worker --without-heartbeat -l DEBUG --config=c26_message.celeryconfig --loglevel=INFO --logfile=/var/log/celery/worker1.log --pidfile=/var/run/celery/worker1.pid --hostname=worker1@worker1@worker1@worker1@%h
celery 26664 1.6 0.7 860384 59624 ? Sl 18:41 0:00 /usr/bin/python -m celery worker --without-heartbeat -l DEBUG --config=c26_message.celeryconfig --loglevel=INFO --logfile=/var/log/celery/worker1.log --pidfile=/var/run/celery/worker1.pid --hostname=worker1@worker1@worker1@worker1@%h
celery 26665 0.2 0.7 270272 59672 ? S 18:41 0:00 /usr/bin/python -m celery worker --without-heartbeat -l DEBUG --config=c26_message.celeryconfig --loglevel=INFO --logfile=/var/log/celery/worker1.log --pidfile=/var/run/celery/worker1.pid --hostname=worker1@worker1@worker1@worker1@%h
celery 26668 5.3 0.8 270340 66656 ? S 18:41 0:02 /usr/bin/python -m celery worker --without-heartbeat -l DEBUG --config=c26_message.celeryconfig --loglevel=INFO --logfile=/var/log/celery/worker3.log --pidfile=/var/run/celery/worker3.pid --hostname=worker3@worker3@worker3@worker3@%h
celery 26682 0.3 0.7 270272 58048 ? S 18:42 0:00 /usr/bin/python -m celery worker --without-heartbeat -l DEBUG --config=c26_message.celeryconfig --loglevel=INFO --logfile=/var/log/celery/worker2.log --pidfile=/var/run/celery/worker2.pid --hostname=worker2@worker2@worker2@worker2@%h
celery 26683 0.1 0.7 270272 58044 ? S 18:42 0:00 /usr/bin/python -m celery worker --without-heartbeat -l DEBUG --config=c26_message.celeryconfig --loglevel=INFO --logfile=/var/log/celery/worker2.log --pidfile=/var/run/celery/worker2.pid --hostname=worker2@worker2@worker2@worker2@%h
celery 26684 0.3 0.7 270272 58044 ? S 18:42 0:00 /usr/bin/python -m celery worker --without-heartbeat -l DEBUG --config=c26_message.celeryconfig --loglevel=INFO --logfile=/var/log/celery/worker2.log --pidfile=/var/run/celery/worker2.pid --hostname=worker2@worker2@worker2@worker2@%h
celery 26685 0.2 0.7 270272 58108 ? S 18:42 0:00 /usr/bin/python -m celery worker --without-heartbeat -l DEBUG --config=c26_message.celeryconfig --loglevel=INFO --logfile=/var/log/celery/worker2.log --pidfile=/var/run/celery/worker2.pid --hostname=worker2@worker2@worker2@worker2@%h
celery 26687 5.5 0.8 270340 66824 ? S 18:42 0:02 /usr/bin/python -m celery worker --without-heartbeat -l DEBUG --config=c26_message.celeryconfig --loglevel=INFO --logfile=/var/log/celery/worker4.log --pidfile=/var/run/celery/worker4.pid --hostname=worker4@worker4@worker4@worker4@%h
celery 26696 0.1 0.7 270272 58036 ? S 18:42 0:00 /usr/bin/python -m celery worker --without-heartbeat -l DEBUG --config=c26_message.celeryconfig --loglevel=INFO --logfile=/var/log/celery/worker3.log --pidfile=/var/run/celery/worker3.pid --hostname=worker3@worker3@worker3@worker3@%h
celery 26697 1.3 0.7 861124 60648 ? Sl 18:42 0:00 /usr/bin/python -m celery worker --without-heartbeat -l DEBUG --config=c26_message.celeryconfig --loglevel=INFO --logfile=/var/log/celery/worker3.log --pidfile=/var/run/celery/worker3.pid --hostname=worker3@worker3@worker3@worker3@%h
celery 26698 0.1 0.7 270272 58032 ? S 18:42 0:00 /usr/bin/python -m celery worker --without-heartbeat -l DEBUG --config=c26_message.celeryconfig --loglevel=INFO --logfile=/var/log/celery/worker3.log --pidfile=/var/run/celery/worker3.pid --hostname=worker3@worker3@worker3@worker3@%h
celery 26699 0.1 0.7 270272 58100 ? S 18:42 0:00 /usr/bin/python -m celery worker --without-heartbeat -l DEBUG --config=c26_message.celeryconfig --loglevel=INFO --logfile=/var/log/celery/worker3.log --pidfile=/var/run/celery/worker3.pid --hostname=worker3@worker3@worker3@worker3@%h
celery 26701 0.0 0.7 270272 57720 ? S 18:42 0:00 /usr/bin/python -m celery worker --without-heartbeat -l DEBUG --config=c26_message.celeryconfig --loglevel=INFO --logfile=/var/log/celery/worker4.log --pidfile=/var/run/celery/worker4.pid --hostname=worker4@worker4@worker4@worker4@%h
celery 26702 0.0 0.6 270080 53260 ? S 18:42 0:00 /usr/bin/python -m celery worker --without-heartbeat -l DEBUG --config=c26_message.celeryconfig --loglevel=INFO --logfile=/var/log/celery/worker4.log --pidfile=/var/run/celery/worker4.pid --hostname=worker4@worker4@worker4@worker4@%h
celery 26703 0.0 0.7 270272 57268 ? S 18:42 0:00 /usr/bin/python -m celery worker --without-heartbeat -l DEBUG --config=c26_message.celeryconfig --loglevel=INFO --logfile=/var/log/celery/worker4.log --pidfile=/var/run/celery/worker4.pid --hostname=worker4@worker4@worker4@worker4@%h
celery 26704 0.0 0.7 270272 57336 ? S 18:42 0:00 /usr/bin/python -m celery worker --without-heartbeat -l DEBUG --config=c26_message.celeryconfig --loglevel=INFO --logfile=/var/log/celery/worker4.log --pidfile=/var/run/celery/worker4.pid --hostname=worker4@worker4@worker4@worker4@%h
root 26740 0.0 0.0 14196 984 pts/5 S+ 18:42 0:00 grep --color=auto celery worker
芹菜花也展示了20名工人,其中16名离线,4名在线。怎么可能?
答案 0 :(得分:0)
根本原因是创建了4个节点,并根据CPU数量进行默认的一致性设置。因此,您可以看到每个节点创建了5个进程。
通过参考下面的示例设置每个并发节点,为每个CPU设置一个节点:
CELERYD_OPTS="-c 4 -c:worker4 1 -c:worker3 1 -c:worker2 1 -c:worker1 1"
可以参考celery文档的示例配置:http://docs.celeryproject.org/en/latest/userguide/daemonizing.html#example-configuration