---
title: "FastAPI backend performance cleanup"
url: "https://ramenm.com/en/projects/fastapi-backend-performance"
markdown_url: "https://ramenm.com/en/projects/fastapi-backend-performance/index.md"
locale: "en"
content_language: "en"
page_kind: "project"
source: "localized_path"
llms_url: "https://ramenm.com/llms.txt"
llms_full_url: "https://ramenm.com/llms-full.txt"
---

# FastAPI backend performance cleanup

- Case study URL: https://ramenm.com/en/projects/fastapi-backend-performance
- Markdown URL: https://ramenm.com/en/projects/fastapi-backend-performance/index.md
- Role: Python Backend Developer
- Period: 2024-2025
- Team: Solo / contract-style work

Optimization of a FastAPI API path: async I/O, connection reuse, Redis cache, request validation, metrics, and removal of serial bottlenecks.

## Problem
A hot API path spent too much time in serial waits and repeated dependency calls. The first step was to measure it instead of guessing.

## Solution
Built a benchmark profile, isolated slow dependencies, changed the request path around async I/O, connection pooling, caching, and clearer validation.

## Impact
In the repeatable benchmark profile, throughput moved from about 1,600 to about 8,200 RPS and p95 latency dropped by about 70%.

## Stack
- Python, FastAPI, asyncio, Pydantic, Redis, PostgreSQL, SQLAlchemy, Docker / Docker Compose, REST APIs / Webhooks, Prometheus / monitoring / logging

## Metrics
- Throughput: ~1.6k -> ~8.2k RPS
- Latency: p95 about -70%
- Scope: Benchmark profile

## Highlights
- Measured the current path before changing the implementation.
- Moved repeatable benchmark throughput from about 1,600 to about 8,200 RPS.
- Reduced p95 latency by about 70% in the same benchmark profile.

## Lessons
- Performance work is easier to trust when the baseline and test shape are written down.
- The best optimization is often removing avoidable waits, not adding clever code.
