python - How to run Flask with Gunicorn in multithreaded mode -
i have web application written in flask. suggested everyone, can't use flask in production. thought of gunicorn flask.
in flask application loading machine learning models. these of size 8gb collectively. concurrency of web application can go upto 1000 requests. , ram of machine 15gb.
best way run application?
you can start app multiple workers or async workers gunicorn.
flask server.py
from flask import flask app = flask(__name__) @app.route("/") def hello(): return "hello world!" if __name__ == "__main__": app.run()
gunicorn gevent async worker
gunicorn server:app -k gevent --worker-connections 1000
gunicorn 1 worker 12 threads:
gunicorn server:app -w 1 --threads 12
gunicorn 4 workers (multiprocessing):
gunicorn server:app -w 4
more information on flask concurrency in post: how many concurrent requests single flask process receive?.
Comments
Post a Comment