I am new to this, but by comparing the code of gunicorn with flask/werkzeug, I fail to understand the real benefit of inserting gunicorn between nginx and flask. Would like to get some expert opinions on this.
For what I understand so far, it boils down to comparing gunicorn with werkzeug's dev server. In short, I fail to understand why werkzeug's server is called a dev server, while gunicorn is considered prod ready. The argument for choosing gunicorn over werkzeug that I can think of:
Are the reasons above valid? What are the other reasons?
Btw, I have read SO post 1 and SO post 2 but they do not seem to fully answer my questions yet.
Werkzeug can use multiple processes, but spins up a new process on each request. That's great if you're slapping something together that so thoroughly pollutes its environment that discarding the process after each request is necessary, but isn't the most performance-friendly approach to deploying an app.
gunicorn (or uwsgi, which I prefer) provides process management that's considerably more flexible than what Werkzeug provides.
You might be convinced, though, by throwing together a simple app, setting it up for 4 processes using werkzeug for one experiment, and gunicorn or uwsgi for the other, and then measuring its performance as you throw traffic at it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With