This proof-of-concept compares performance and integration between Flask and FastAPI using two different backends:
- Apache DataFusion (in-process SQL engine over Parquet)
- PostgreSQL (traditional RDBMS)
virtualenv --python=$(which python3.10) .venv
source .venv/bin/activate
pip install -r requirements.txt
Create a .env file with the following content:
export DB_NAME="test"
export DB_USER="admin"
export DB_PASSWORD="admin"
export DB_HOST="localhost"
export DB_PORT="5432"
Then load the environment variables:
source .env
You can either:
- Run a local PostgreSQL instance manually, or
- Use Docker (see Docker section below)
pytest tests/test_query_engine.py -s -k test_setup_db
PYTHONPATH=. uvicorn fastapi_app.app:app --reload
PYTHONPATH=. python flask_app/app.py
docker compose up --build -d
- Flask app is exposed on
http://localhost:3000 - Fast api is exposed on
http://localhost:3001 - PostgreSQL runs inside the
analytics_dbcontainer
ab -n 10000 -c 200 -l http://localhost:3001/datafusion