talira

Gunicorn

Python WSGI HTTP server for UNIX

open sourceMITself-hostablefree

Gunicorn ('Green Unicorn') is a Python HTTP server for UNIX that runs WSGI applications from Django, Flask, Pyramid and any other WSGI framework, and ASGI applications from FastAPI, Starlette and Quart through its asgi worker. It uses a pre-fork worker model ported from Ruby's Unicorn: a master process manages a pool of workers, with sync, gthread, gevent and asgi worker types, graceful restarts and reloads on signals. It has beta HTTP/2 support with multiplexed streams, beta dirty arbiters for heavy workloads such as ML models, the uWSGI binary protocol and PROXY protocol, StatsD instrumentation and a configuration file or command-line settings. Its docs strongly recommend running it behind a proxy such as nginx. It needs Python 3.10 or later, is MIT-licensed, and is maintained by volunteers led by Benoît Chesneau since 2010.

Problems it solves

  • run my Django or Flask app in production instead of the development server
  • serve a FastAPI app with multiple worker processes
  • a WSGI server to put behind nginx
  • restart Python web workers gracefully without dropping requests during a deploy
  • run Python web app workers with threads or gevent for many concurrent connections
  • send web server metrics to StatsD or Datadog
  • keep a heavy ML model loaded in separate processes behind my Python web app

Features

  • WSGI support for Django, Flask, Pyramid and any WSGI framework
  • ASGI support for FastAPI, Starlette and Quart
  • worker types: sync, gthread, gevent and asgi
  • pre-fork master and worker process model with graceful worker management
  • HTTP/2 with multiplexed streams (beta)
  • dirty arbiters for heavy workloads such as ML models (beta)
  • uWSGI binary protocol for nginx integration
  • PROXY protocol support
  • StatsD and DogStatsD instrumentation
  • configuration by file, environment or command line; signal handling for reloads
View 1 more
  • Docker deployment guide

Limitations

  • Runs only on UNIX: it is a server for UNIX-like systems, not Windows12
  • Meant to sit behind a proxy: the docs strongly recommend putting it behind a proxy server such as nginx12
  • HTTP/2 is still beta: HTTP/2 support and dirty arbiters are marked beta12

Capabilities

Has a command line toolplan not known
Takes pluginsplan not known

Alternatives

The same job

These do what Gunicorn does.

  1. Puma A Ruby/Rack web server built for parallelism

Compare Gunicorn with the top 3