ASGI

Asynchronous Server Gateway Interface (ASGI) is standard interface between async-capable web servers, frameworks, and applications written on Python language. pygeoapi itself doesn’t implement ASGI since it is an API, therefore it is required a webframework to access HTTP requests and pass the information to pygeoapi

HTTP request --> Starlette (starlette_app.py) --> pygeoapi API

the pygeoapi package integrates starlette_app as webframework for defining the API routes/end points and WSGI support.

The starlette ASGI server can be easily run as a pygeoapi command with the option –starlette:

pygeoapi serve --starlette

Running a Uvicorn server is not advisable, the preferred option is as follows:

HTTP request --> ASGI server (gunicorn) --> Starlette (starlette_app.py) --> pygeoapi API

By having a specific ASGI server, the HTTPS are efficiently processed into threads/processes. The current docker pygeoapi implement such strategy (see section: Docker), it is prefered to implement pygeopai using docker solutions than running host native ASGI servers.

Running gunicorn

Uvicorn includes a Gunicorn worker class allowing you to run ASGI applications, with all of Uvicorn’s performance benefits, while also giving you Gunicorn’s fully-featured process management. This server is simple to run from the command, e.g:

gunicorn pygeoapi.starlette_app:app -w 4 -k uvicorn.workers.UvicornWorker

For extra configuration parameters like port binding, workers please consult the gunicorn settings