项目是采用 gunicorn dango nginx 方式部署的。
gunicorn.py采用如下方式配置,
workers = 1 bind = '0.0.0.0:8000' backlog = 2048 timeout = 6000 keepalive = 6000 errorlog = '../error.log' loglevel = 'info' logFile = '../sys.log' accesslog = '../access.log' worker_class = 'gthread' worker_connections = 1000
/etc/systemd/system/cmdb.service
[root@localhost system]# cat cmdb.service [Unit] Description=cmdb After=network.target [Service] User=root Group=root Environment="APP_ENV=prd" WorkingDirectory=/data/cmdb/ ExecStart=/usr/local/bin/gunicorn cmdb.wsgi:application -c /data/cmdb/gunicorn.py [Install] WantedBy=multi-user.target
之后启动systemctl start cmdb。程序没问题,有问题的地方是有一个耗时很长的同步任务,会导致页面,程序接口都卡着。就很好奇,gunicorn不就是异步的么,难道不能处理类似的并发请求?
经过一番折腾,python - 如何让 Flask/Gunicorn 处理同一路由的并发请求? gunicorn使用
解决办法:
加上threads就解决了
把gunicorn.py 改下,重启systemctl restart cmdb,完美解决。
workers = 1 bind = '0.0.0.0:8000' backlog = 2048 timeout = 6000 keepalive = 6000 errorlog = '../error.log' loglevel = 'info' logFile = '../sys.log' accesslog = '../access.log' worker_class = 'gthread' worker_connections = 1000 threads = 2
标签:gunicorn,..,worker,nginx,dango,6000,cmdb,log From: https://www.cnblogs.com/sdadx/p/17730834.html