Django+celery,配置并发数不生效

Django+celery,配置并发数不生效

Django setting.py

CELERY_RESULT_BACKEND = 'django-db'

CELERY_BROKER_URL = 'redis://127.0.0.1/0'

CELERYD_CONCURRENCY = 2 # 并发worker数

# CELERYD_PREFETCH_MULTIPLIER=1

CELERYD_FORCE_EXECV = True

CELERYD_MAX_TASKS_PER_CHILD = 50

启动命令:celery -A san worker -l INFO -P gevent

 -------------- celery@dev.10.1.1.209 v5.2.3 (dawn-chorus)

--- ***** -----

-- ******* ---- Linux-3.10.0-327.el7.x86_64-x86_64-with-glibc2.17 2022-02-18 14:31:44

- *** --- * ---

- ** ---------- [config]

- ** ---------- .> app: san:0x7f7d31a811c0

- ** ---------- .> transport: redis://127.0.0.1:6379/0

- ** ---------- .> results:

- *** --- * --- .> concurrency: 4 (gevent)

-- ******* ---- .> task events: OFF (enable -E to monitor tasks in this worker)

--- ***** -----

-------------- [queues]

.> celery exchange=celery(direct) key=celery

并发数显示的还是4个,我配置的为什么没有生效?
在启动命令指定-c参数是可以生效的.
我的其余配置是生效的CELERY_BROKER_URL,CELERY_RESULT_BACKEND


回答:

# CELERYD_CONCURRENCY = 2  # 不生效

CELERY_WORKER_CONCURRENCY = 2 # 并发worker数

官方实例代码中的注释

# Using a string here means the worker doesn't have to serialize

# the configuration object to child processes.

# - namespace='CELERY' means all celery-related configuration keys

# should have a `CELERY_` prefix.

以上是 Django+celery,配置并发数不生效 的全部内容, 来源链接: utcz.com/p/938330.html

回到顶部