-Gunicorn does not support WIN, all are done under Linux.
-Just run the script like this if __name__ == "__main__":
#app.run(debug=False, host='0.0.0.0', port=8886, threaded=True)
app.run()
- pip install gunicorn
- gunicorn -w 4 -b 0.0.0.0:8080 main:app
-w is the number of work, set four -b to specify the port, main is the name of your script, app is the name of your flask application.
Figure 4 process
Video memory is naturally 4 times.
supplement:
pip install vent
New configuration file: vim gunicorn.py
import os
import gevent.monkey
gevent.monkey.patch_all()
import multiprocessing
# backlog = 512 #监听队列
# debug = True # debug开启
# threads = 2 # 指定每个进程开启的线程数
# daemon = True # 表示开启后台运行,默认False
loglevel = 'debug'
bind = "0.0.0.0:5001" # 绑定的ip和端口号
# /var/log/WEB_APP 目录必须存在
# pidfile = "/var/log/WEB_APP/gunicorn.pid"
# accesslog = "/var/log/WEB_APP/access.log"
# access_log_format = '%(t)s %(p)s %(h)s "%(r)s" %(s)s %(L)s %(b)s %(f)s" "%(a)s"'
#设置守护进程
#daemon=True
#设置超时时间120s。默认为30s
timeout=120
#设置访问日志与错误信息日志路径
errorlog = "./error.log"
# 启动的进程数
#workers = multiprocessing.cpu_count() # 这里取的是CPU的数量
workers = 4 # 进程数,
worker_class = 'gevent' # worker_class是指开启的每个工作进程的模式类型,默认为sync模式,这里使用gevent模式
x_forwarded_for_header = 'X-FORWARDED-FOR'
Run gunicorn manager02:app -c gunicorn.py (manager02 is the name of the script, app is the name of the application in flask) really high concurrency (until the CPU bottleneck is reached?)
## 2021 01 25
- fastapi
- pip install fastapi
pip install uvicorn
uvicorn fast_api:app --workers 3 --port 5000