You can deploy FastAPI manually as well.
You just need to install an ASGI compatible server like:
- Uvicorn, a lightning-fast ASGI server, built on uvloop and httptools.
$ pip install uvicorn[standard] ---> 100%
By adding the
standard, Uvicorn will install and use some recommended extra dependencies.
uvloop, the high-performance drop-in replacement for
asyncio, that provides the big concurrency performance boost.
- Hypercorn, an ASGI server also compatible with HTTP/2.
$ pip install hypercorn ---> 100%
...or any other ASGI server.
And run your application the same way you have done in the tutorials, but without the
--reload option, e.g.:
$ uvicorn main:app --host 0.0.0.0 --port 80 <span style="color: green;">INFO</span>: Uvicorn running on http://0.0.0.0:80 (Press CTRL+C to quit)
$ hypercorn main:app --bind 0.0.0.0:80 Running on 0.0.0.0:8080 over http (CTRL + C to quit)
You might want to set up some tooling to make sure it is restarted automatically if it stops.
Making sure to fine-tune the number of workers, etc.
But if you are doing all that, you might just use the Docker image that does it automatically.