推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
taomujian
V2EX  ›  Python

python3 rq worker 数量是多少?

  •  
  •   taomujian · Dec 7, 2021 · 2288 views
    This topic created in 1641 days ago, the information mentioned may be changed or developed.
    def worker(listen):
        with Connection(redis_conn):
            worker = Worker(map(Queue, listen))
            worker.work()
    
    def run ():
        listen = ['high', 'scheduler']
        try:
            cpu_num = 2
            p = Pool(cpu_num)
            for i in range(cpu_num):
                p.apply_async(worker, args=(listen,))  # 开启 worker
            p.close()
            p.join()
        except Exception as e:
            print(e)
    

    主机为 1CPU,4 核

    运行程序后,加入队列的任务有点多(500 多个),在前台看了下处于正在处理的任务有 16 个,这是怎么计算出来的啊?生产环境中用 gunicorn 部署的,fastapi 框架,gunicorn workers 为 4,threads 为 5

    deplivesb
        1
    deplivesb  
       Dec 7, 2021
    gunicorn workers * cpu_core
    taomujian
        2
    taomujian  
    OP
       Dec 7, 2021
    @deplivesb 这个计算方式有什么依据吗?
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2929 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 30ms · UTC 06:51 · PVG 14:51 · LAX 23:51 · JFK 02:51
    ♥ Do have faith in what you're doing.