python-3.xkubernetesfastapiazure-aksuvicorn

During uvicorn startup, child process dies in a Kubernetes cluster


We are using FastAPI version 0.111.0 for our application. The uvicorn server is started as shown below:

  uvicorn.run(
                "main:app",
                host='0.0.0.0',
                port=8080,
                log_level="DEBUG",
                workers=3
            )

This works on a Windows machine during our development/test environment. When we deploy this code to the Azure Kubernets cluster, during startup the child process dies.

Error message:

INFO:     Uvicorn running on http://0.0.0.0:8080 (Press CTRL+C to quit)
INFO:     Started parent process [1]
INFO:     Waiting for child process [12]
INFO:     Child process [12] died
INFO:     Waiting for child process [13]
INFO:     Child process [13] died
INFO:     Waiting for child process [14]
INFO:     Child process [14] died
INFO:     Waiting for child process [13]
INFO:     Child process [13] died
INFO:     Waiting for child process [15]

If we remove the workers argument for the uvicoen.run call, the application starts in AKS. I would like to understand, why the child process dies with the workers argument.


Solution

  • It seems, this is a bug: https://github.com/encode/uvicorn/discussions/2372

    It will be fixed at v0.30.2: https://github.com/encode/uvicorn/pull/2380