Python - Granian

Granian is a Rust-based HTTP server for Python applications. It supports ASGI/3, RSGI (for Rust), and WSGI interface applications. It also implements HTTP/1 and HTTP/2 protocols and supports HTTPS and websockets.

I chose Granian over my other recommended app servers because of the performance stats. In particular, not the average best times but because of the lower worst times.

FastAPI

Granian (like many other high-performance servers) uses multiprocessing to handle requests. This means that it spawns multiple worker processes to handle incoming requests concurrently. Each worker process runs independently and can handle requests in parallel.

You should pass the import path string of your application instead of the object itself. This way, each worker process will import the application independently.

Added interface="asgi" because FastAPI is an ASGI application. Granian supports multiple interfaces (ASGI, RSGI, WSGI), and it’s best to be explicit when using the programmatic API.

from fastapi import FastAPI
from granian.server import Server
app = FastAPI()
if __name__ == "__main__":
# https://github.com/emmett-framework/granian/blob/master/granian/cli.py
server = Server("main:app", interface="asgi")
server.serve()

Pending