explaingit

benoitc/gunicorn

10,569PythonAudience · developerComplexity · 2/5LicenseSetup · easy

TLDR

Gunicorn is a Python web server that sits between nginx and your Python app, handling incoming HTTP requests and distributing them across worker processes so multiple users can be served at the same time.

Mindmap

mindmap
  root((gunicorn))
    What it does
      Serves Python apps
      Handles HTTP requests
      Pre-fork workers
    Worker Types
      Sync worker
      Threaded worker
      Gevent async
      ASGI worker
    Use Cases
      Django production
      Flask deployment
      FastAPI async
    Setup
      pip install
      One command start
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Things people build with this

USE CASE 1

Serve a Django or Flask app in production with multiple parallel workers by running a single Gunicorn command

USE CASE 2

Run a FastAPI or Starlette app using Gunicorn's ASGI worker type for async request handling

USE CASE 3

Handle long-running machine learning inference requests using the Dirty Arbiters feature added in version 25

Tech stack

PythonWSGIASGIgeventHTTP/2

Getting it running

Difficulty · easy Time to first run · 5min
Use freely for any purpose, including commercial, as long as you keep the copyright notice.

In plain English

Gunicorn, short for Green Unicorn, is a web server for Python applications. Its specific job is to sit between a reverse proxy like nginx and your Python web application, handling the work of accepting incoming HTTP requests and passing them to your app code. It follows a standard called WSGI, which defines how Python web frameworks and web servers talk to each other, meaning it works with Django, Flask, Pyramid, and most other Python web frameworks without any special configuration. The way Gunicorn manages work is called the pre-fork worker model. When it starts, it launches several worker processes that each wait for requests. This lets it handle multiple visitors at the same time across separate processes, which is important for running a real production website. You control how many workers run with a single flag. Several worker types are available: a basic synchronous worker, a threaded worker, an asynchronous worker using the gevent library, and an ASGI worker for newer Python frameworks like FastAPI and Starlette. Version 25 added beta support for HTTP/2, the newer version of the web protocol that allows multiplexed streams, meaning multiple requests can share one connection. It also introduced a feature called Dirty Arbiters for workloads where individual requests take a long time, such as running machine learning models. Installing Gunicorn is one pip command. Starting it requires pointing it at your application object with a command like gunicorn myapp:app. Full documentation covering quickstart, configuration, and deployment is available at the project's website. Gunicorn is released under the MIT license and has been maintained by volunteers since 2010. The README notes it is volunteer-maintained and asks organizations running it in production to consider sponsoring the project.

Copy-paste prompts

Prompt 1
Show me how to configure Gunicorn to serve my Flask app with 4 synchronous workers and log requests to a file.
Prompt 2
Write a Gunicorn config file that uses gevent async workers and sets a 30-second timeout for my Django app.
Prompt 3
How do I set up Gunicorn with nginx as a reverse proxy for a production Python web app?
Prompt 4
Generate a systemd service file that starts a Gunicorn ASGI worker for my FastAPI application on boot.
Open on GitHub → Explain another repo

← benoitc on gitmyhub — every repo by this author, as a profile.

Verify against the repo before relying on details.