Granian

High-performance Rust-based server supporting both ASGI and WSGI.

Use when: Maximum performance, modern deployments Don’t use when: Need mature ecosystem (use Gunicorn or ASGI Mode)

Installation

pip install django-prodserver[granian]

Backends

ASGI Mode

For async Django with WebSocket support:

PRODUCTION_PROCESSES = {
    "web": {
        "BACKEND": "django_prodserver.backends.servers.granian.GranianASGIServer",
        "ARGS": {
            "address": "0.0.0.0",
            "port": "8000",
            "workers": "4",
        }
    }
}

WSGI Mode

For traditional Django:

PRODUCTION_PROCESSES = {
    "web": {
        "BACKEND": "django_prodserver.backends.servers.granian.GranianWSGIServer",
        "ARGS": {
            "address": "0.0.0.0",
            "port": "8000",
            "workers": "4",
        }
    }
}

Common ARGS

Argument

Default

Description

address

127.0.0.1

Address to bind

port

8000

Port to bind

workers

1

Worker processes

threads

1

Threads per worker (WSGI)

blocking-threads

1

Blocking threads (ASGI)

backlog

1024

Connection backlog

http

auto

HTTP version (auto, 1, 2)

log-level

info

Log level

log-access

True

Enable access logging

ssl-cert

None

SSL certificate path

ssl-key

None

SSL key path

Examples

High-Performance ASGI

"ARGS": {
    "address": "0.0.0.0",
    "port": "8000",
    "workers": "4",
    "blocking-threads": "2",
    "log-access": "False",
}

WSGI with Thread Pool

"ARGS": {
    "address": "0.0.0.0",
    "port": "8000",
    "workers": "2",
    "threads": "4",
}

HTTP/2

"ARGS": {
    "http": "2",
    "workers": "4",
}

ASGI vs WSGI

Feature

ASGI

WSGI

Async views

Yes

No

WebSockets

Yes

No

Thread model

Async + blocking

Thread pool

Troubleshooting

Installation fails: Granian requires Rust on some platforms. Try pip install --upgrade granian

ASGI app not found: Ensure asgi.py exists