Deploying for concurrent access

Until now, we were in the development stage and we could easily use the development server that comes packaged with Flask to quickly test our changes. But this development server is not a good choice if you are planning to run the application in production, and we need something more dedicated for that. This is because, in a production environment, we will be more concerned about the concurrency of the application, as well as its security aspects, like enabling SSL and providing more restricted access to some of the endpoints.

So, we need to figure out some choices here based on the fact that we need our application to handle a lot of concurrent accesses, while constantly maintaining a good response time for the users.

With this in mind, we end up with the following set of choices, which, by their nature are also fairly common in many production environments:

  • Application server: Gunicorn
  • Reverse Proxy: Nginx

Here, Gunicorn will be the application that will be responsible for handling the requests that are to be served by our Flask application, while Nginx takes care of request queuing and handling the distribution of the static assets.

So, first, let's set up Gunicorn and how we are going to serve the application through it.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.118.2.225