- Websockets
- FastApi request models / no models
- Frontend för att visa datan i d3?
Ruff is used for python linting
ruff . --fix
Basic usage
./benchmark.sh [flags]
./benchmark.sh -t 30s -u http://localhost:7777 -m only -s '["raw_json"]'
Usage help
./benchmark.sh -h
Usage: benchmark.sh [flags]
-h Show help menu
-l List all available stages
-m <mode> Mode: full, skip, only, low_load (full)
-r <rate> Requests per second, 0=inf (0)
-s <stages> Stages to include/exclude as JSON array, e.g., '["raw_json", "parse_url", "delay"]' (all)
-t <duration> Duration in si units (1s, 5m, 10h)
-u <url> Base URL of benchmark (http://localhost:5000)
-w <max_workers> Maximum number of workers for vegeta (100)
Due to MacOs shiping with bash 3.2 and this program relying on newer bash features. ./benchmark.sh
points to a newer version of bash installed with brew.
If running on MacOs do
brew install bash
Remove the first line of the code in ./benchmark.sh
.
The first line should be the path to your bash installation example: #!/bin/bash
To view the results of the benchmark use vegeta report
, e.g.
vegeta report result.bin
vegeta report -type=json results.bin > metrics.json
vegeta results.bin plot > plot.html
vegeta report -type="hist[0,100ms,200ms,300ms]" results.bin
FastAPI presented with uvicorn under gunicorn
Create venv
/path/to/python -m venv ./venv
Activate venv
source ./venv/bin/activate
Install requirements
pip install -r ./requirements.txt
start development server:
uvicorn main:app --reload
start production server:
gunicorn -k uvicorn.workers.UvicornWorker -w 12 -b 0.0.0.0:7777 main:app
Create image:
docker build -t fastapi .
Start image:
docker run -d -p 7777:7777 --name fastapi fastapi
Presented with Gunicorn running gevent workers
Create venv
/path/to/python -m venv ./venv
Activate venv
source ./venv/bin/activate
Install requirements
pip install -r ./requirements.txt
Start development server:
flask
Start production server:
gunicorn -w 8 -b 0.0.0.0:7778 app:app
Create image:
docker build -t flask .
Start image:
docker run -d -p 7778:7778 --name flask flask
Install dependencies
yarn
Start dev server
yarn dev