How to run Flask with Gunicorn in multithreaded mode

前端 未结 2 1598
孤城傲影
孤城傲影 2020-11-30 20:20

I have web application written in Flask. As suggested by everyone, I can\'t use Flask in production. So I thought of Gunicorn with Flask.

In Flask

2条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-11-30 20:25

    The best thing to do is to use pre-fork mode (preload_app=True). This will initialize your code in a "master" process and then simply fork off worker processes to handle requests. If you are running on linux and assuming your model is read-only, the OS is smart enough to reuse the physical memory amongst all the processes.

提交回复
热议问题