返回案例
2024-2025Solo / contract-style work

FastAPI backend performance cleanup

优化 FastAPI API path:async I/O、connection reuse、Redis cache、request validation、metrics 和移除 serial bottlenecks。

Throughput
~1.6k -> ~8.2k RPS
Latency
p95 about -70%
Scope
Benchmark profile
Measured backend work

先 baseline,再一次处理一个 bottleneck。

这些数字是 repeatable benchmark profile,不是模糊的 production promise。

1修改代码前先建立 baseline
2移除 serial waits 和 repeated dependency calls
3加入 cache strategy、connection reuse 和更清晰的 validation
角色

Python 后端开发者

技术栈
PythonFastAPIasyncioPydanticRedis
问题

Hot API path 在 serial waits 和 repeated dependency calls 上花了太多时间。第一步是测量,而不是猜。

方案

建立 benchmark profile,隔离 slow dependencies,并围绕 async I/O、connection pooling、caching 和更清晰的 validation 改造 request path。

结果

在 repeatable benchmark profile 中,throughput 从约 1,600 提升到约 8,200 RPS,p95 latency 约降低 70%。

我做了什么
  • 修改 implementation 前先测量当前 path。
  • 把 repeatable benchmark throughput 从约 1,600 提升到约 8,200 RPS。
  • 在同一 benchmark profile 中将 p95 latency 约降低 70%。
这说明了什么
  • 写下 baseline 和 test shape 后,performance work 更可信。
  • 最好的优化常常是移除 avoidable waits,而不是增加 clever code。
相关项目

更多项目

2025-2026

nnzen 模型目录

Solo

实时 LLM 模型目录:收集模型数据、统一格式,并让模型比较更快完成。

PythonFastAPILLM APIsRAGVector DB / pgvector
2025

MCP core for an LLM assistant

Solo

LLM assistant 的 backend core,包含 plugin execution、hot reload、tool chains 和 explicit context handoff。

PythonFastAPIMCPTool callingLLM APIs