Skip to content

Latest commit

 

History

History
82 lines (61 loc) · 2.09 KB

README.md

File metadata and controls

82 lines (61 loc) · 2.09 KB

FastAPI with async background tasks + Prometheus + Grafana

This project provides a way to setup and run asynchronous (async/await) tasks using these libraries:

This way can also be useful for testing your code with eager execution. You can see it in tests/conftest.py.

Finally, it shows how to monitor FastAPI app and execution of tasks with Prometheus + Grafana using these libraries:


Installation

Clone the repository:

git clone https://github.com/ipakeev/fastapi-async-tasks

Usage

Create .env file and adjust it:

cp example.env .env

Build app image:

docker build -t fastapi-async-tasks .

Run all containers:

docker-compose up

Now you have access to these services:

Raw metrics are available here:


Benchmark

You can test the performance of the application and run a benchmark using locust:

env endpoint={endpoint} locust --config locust/master.conf -f locust/benchmark.py -u 10 -i 1000
env endpoint={endpoint} locust --config locust/master.conf -f locust/background.py -u 10 -i 1000

Available {endpoint}s:

  • io/simple
  • io/sync
  • io/thread
  • cpu/simple
  • cpu/process