---
title: "FastAPI backend performance cleanup"
url: "https://ramenm.com/ru/projects/fastapi-backend-performance"
markdown_url: "https://ramenm.com/ru/projects/fastapi-backend-performance/index.md"
locale: "ru"
content_language: "ru"
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/ru/projects/fastapi-backend-performance
- Markdown URL: https://ramenm.com/ru/projects/fastapi-backend-performance/index.md
- Role: Python backend-разработчик
- Period: 2024-2025
- Team: Solo / contract-style work

Оптимизация FastAPI API path: async I/O, connection reuse, Redis cache, request validation, metrics и удаление serial bottlenecks.

## Problem
Hot API path тратил слишком много времени на serial waits и repeated dependency calls. Сначала нужно было измерить, а не угадывать.

## Solution
Собрал benchmark profile, изолировал slow dependencies, изменил request path вокруг async I/O, connection pooling, caching и более ясной validation.

## Impact
В repeatable benchmark throughput вырос примерно с 1,600 до 8,200 RPS, p95 latency снизилась примерно на 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
- Измерил текущий path до изменения implementation.
- Поднял repeatable benchmark throughput примерно с 1,600 до 8,200 RPS.
- Снизил p95 latency примерно на 70% в том же benchmark.

## Lessons
- Performance work вызывает больше доверия, когда baseline и test shape записаны.
- Лучшая оптимизация часто в том, чтобы убрать avoidable waits, а не добавить clever code.
