Skip to main content

About

Gunicorn ‘Green Unicorn’ is a Python WSGI HTTP Server for UNIX. It’s a pre-fork worker model ported from Ruby’s Unicorn project. The Gunicorn server is broadly compatible with various web frameworks, simply implemented, light on server resource usage, and fairly speedy.

Feel free to join us in #gunicorn on freenode.

Build Status

Documentation

http://docs.gunicorn.org

Installation

Gunicorn requires Python 2.x >= 2.6 or Python 3.x >= 3.1.

Install from sources:

$ python setup.py install

Or from Pypi:

$ pip install -U gunicorn

You may also want to install Eventlet or Gevent if you expect that your application code may need to pause for extended periods of time during request processing. If you’re on Python 3 you may also consider one othe Asyncio workers. Check out the FAQ for more information on when you’ll want to consider one of the alternate worker types.

To install eventlet:

$ pip install -U eventlet

If you encounter errors when compiling the extensions for Eventlet or Gevent you most likely need to install a newer version of libev or libevent.

Basic Usage

After installing Gunicorn you will have access to the command line script gunicorn.

Commonly Used Arguments

  • -c CONFIG, --config=CONFIG - Specify the path to a config file or python module.

  • -b BIND, --bind=BIND - Specify a server socket to bind. Server sockets can be any of $(HOST), $(HOST):$(PORT), or unix:$(PATH). An IP is a valid $(HOST).

  • -w WORKERS, --workers=WORKERS - The number of worker processes. This number should generally be between 2-4 workers per core in the server. Check the FAQ for ideas on tuning this parameter.

  • -k WORKERCLASS, --worker-class=WORKERCLASS - The type of worker process to run. You’ll definitely want to read the production page for the implications of this parameter. You can set this to egg:gunicorn#$(NAME) where $(NAME) is one of sync, eventlet, gevent, or tornado, gthread, gaiohttp`. ``sync is the default.

  • -n APP_NAME, --name=APP_NAME - If setproctitle is installed you can adjust the name of Gunicorn process as they appear in the process system table (which affects tools like ps and top).

    sync=gunicorn.workers.sync:SyncWorker eventlet=gunicorn.workers.geventlet:EventletWorker gevent=gunicorn.workers.ggevent:GeventWorker tornado

There are various other parameters that affect user privileges, logging, etc. You can see the complete list with the expected:

$ gunicorn -h

gunicorn

The first and most basic script is used to serve ‘bare’ WSGI applications that don’t require a translation layer. Basic usage:

$ gunicorn [OPTIONS] APP_MODULE

Where APP_MODULE is of the pattern $(MODULE_NAME):$(VARIABLE_NAME). The module name can be a full dotted path. The variable name refers to a WSGI callable that should be found in the specified module.

Example with test app:

$ cd examples
$ gunicorn --workers=2 test:app

Integration

We also provide integration for both Django and Paster applications.

Django

gunicorn just needs to be called with a the location of a WSGI application object.:

gunicorn [OPTIONS] APP_MODULE

Where APP_MODULE is of the pattern MODULE_NAME:VARIABLE_NAME. The module name should be a full dotted path. The variable name refers to a WSGI callable that should be found in the specified module.

So for a typical Django project, invoking gunicorn would look like:

gunicorn myproject.wsgi:application

(This requires that your project be on the Python path; the simplest way to ensure that is to run this command from the same directory as your manage.py file.)

You can use the –env option to set the path to load the settings. In case you need it you can also add your application path to PYTHONPATH using the –pythonpath option.

Paste

If you are a user/developer of a paste-compatible framework/app (as Pyramid, Pylons and Turbogears) you can use the gunicorn –paste option to run your application.

For example:

gunicorn –paste development.ini -b :8080 –chdir /path/to/project

It is all here. No configuration files nor additional python modules to write !!

Instrumentation

Gunicorn provides an optional instrumentation of the arbiter and workers using the statsD protocol over UDP. Thanks to the gunicorn.instrument.statsd module, Gunicorn becomes a statsD client The use of UDP cleanly isolates Gunicorn from the receiving end of the statsD metrics so that instrumentation does not cause Gunicorn to be heldeup by a slow statsD consumer.

To use statsD, just tell gunicorn where the statsD server is:

$ gunicorn –statsd-host=localhost:8125 …

The Statsd logger overrides gunicorn.glogging.Logger to track all requests. The following metrics are generated:

  • gunicorn.requests: request rate per second

  • gunicorn.request.duration: histogram of request duration

  • gunicorn.workers: number of workers managed by the arbiter (gauge)

  • gunicorn.log.critical: rate of critical log messages

  • gunicorn.log.error: rate of error log messages

  • gunicorn.log.warning: rate of warning log messages

  • gunicorn.log.exception: rate of exceptional log messages

To generate new metrics you can log.info with a few additional keywords:

log.info("...", extra={"metric": "my.metric", "value": "1.2", "mtype": "gauge"})

LICENSE

Gunicorn is released under the MIT License. See the LICENSE file for more details.

Release files for gunicorn 19.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for gunicorn 19.1.0
File Size Uploaded
gunicorn-19.1.0.tar.gz 382.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for gunicorn 19.1.0
File Interpreter ABI Platform
gunicorn-19.1.0-py2.py3-none-any.whl Python 3, Python 2 none any Details

Total release size: 484.8 kB

Release files / gunicorn-19.1.0.tar.gz

Download URL gunicorn-19.1.0.tar.gz
Size 382.4 kB
Tags Source
SHA-256 checksum
How to use checksums
ae1dd6452f62b3470bc9acaf62cb5301545fbb9c697d863a5bfe35097ed7a0b3
BLAKE2b-256 checksum
How to use checksums
a4a338185fd83aa3c850090a25d6045560a66dd55569fd9935b5a673748254ab
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / gunicorn-19.1.0-py2.py3-none-any.whl

Download URL gunicorn-19.1.0-py2.py3-none-any.whl
Size 102.4 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
6b85faf13ec6549eded9f72e4341936732fe396eb995fcaa2c4d6735d6fe9186
BLAKE2b-256 checksum
How to use checksums
eeaace0f2c1886549459c98ab3628a42f1062d79c84b8eca228308f656a95390
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

26.2.0

2 release files

26.1.0

2 release files

25.3.0

2 release files

25.2.0

2 release files

25.1.0

2 release files

24.1.1

2 release files

24.1.0

2 release files

24.0.0

2 release files

23.0.0

2 release files

22.0.0

2 release files

21.2.0

2 release files

21.1.0

2 release files

21.0.1

2 release files

21.0.0

2 release files

20.1.0

2 release files

20.0.4

2 release files

20.0.3

2 release files

20.0.2

2 release files

20.0.1

19.8.1

2 release files

19.8.0

2 release files

19.7.1

2 release files

19.6.0

2 release files

19.5.0

2 release files

19.4.3

2 release files

19.4.2

2 release files

19.4.1

2 release files

19.4.0

2 release files

19.2.0

2 release files

19.1.1

2 release files

This release

19.1.0 This release

2 release files

19.0.0

1 release file

18.0

2 release files

17.5

1 release file

0.17.4

1 release file

0.17.3

1 release file

0.17.2

1 release file

0.17.1

1 release file

0.17.0

1 release file

0.16.1

1 release file

0.16.0

1 release file

0.15.0

1 release file

0.14.6

1 release file

0.14.5

1 release file

0.14.4

1 release file

0.14.3

1 release file

0.14.2

1 release file

0.14.1

1 release file

0.14.0

1 release file

0.13.4

1 release file

0.13.3

1 release file

0.13.2

1 release file

0.13.1

1 release file

0.13.0

1 release file

0.12.2

1 release file

0.12.1

1 release file

0.12.0

1 release file

0.11.2

1 release file

0.11.1

1 release file

0.11.0

1 release file

0.10.1

1 release file

0.10.0

1 release file

0.9.1

1 release file

0.9.0

1 release file

0.8.1

1 release file

0.8.0

1 release file

0.7.2

1 release file

0.7.1

1 release file

0.7.0

1 release file

0.6.6

1 release file

0.6.5

1 release file

0.6.4

1 release file

0.6.3

1 release file

0.6.2

1 release file

0.6.1

1 release file

0.6

1 release file

0.5.1

1 release file

0.5

1 release file

0.4.2

1 release file

0.4.1

1 release file

0.4

1 release file

0.3.2

1 release file

0.3.1

1 release file

0.3

1 release file

0.2.1

1 release file

0.2

1 release file

0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page