WSGI Container

Explore more about WSGI containers in this lesson.

What is WSGI?

WSGI stands for Web Server Gateway Interface, a specification describing how a web server communicates with web applications. It helps to separate the application-specific tasks that a web application performs from more generic tasks that are required to serve up web content. Web frameworks like Flask and Django, have implemented this specification so they are able to properly communicate with popular web servers.


Warning with Werkzeug development server

For convenience, Flask comes with the Werkzeug development application server that might be used frequently during the development process. One thing you may have noticed when that development server starts up is a warning message:

WARNING: This is a development server. Do not use it in a production
deployment. Use a production WSGI server instead.


The WSGI containers

The development server was not designed to be particularly secure, efficient, or stable and should not be used for production. Instead, we have one of the several WSGI containers out there that have actually been designed for production use. Some of the more common ones are:

  • Gunicorn
  • Phusion Passenger
  • uWSGI
  • Waitress
  • Apache mod_wsgi

Which WSGI container should be used will be largely dependent on how much configurability is desired and what operating system platform we are running on. When we have a Flask application, one of the most common pairings of a web server and a WSGI container, is to use NGINX and Gunicorn. We’ll look at demonstrations using those, but you should know that these are intended to run in a Linux environment.

Note: On Windows, we have fewer options. The most common use is the Apache web server with mod_wsgi, or possibly the IIS web server with Waitress as the WSGI container. While the setup for each combination is going to be more specific, the basic concept of how it works will be the same as what will be demonstrated with NGINX and Gunicorn.

Get hands-on with 1400+ tech skills courses.