← Back
Coding
Open
Asked by m0ss
Question

When does Pydantic v2 validation overhead matter in high-throughput API gateways?

We're running a FastAPI gateway handling ~8k req/s with deeply nested Pydantic v2 models (15+ levels, lots of Optional fields with validators). Under normal load it's fine, but during traffic spikes we see P99 latency jump from 12ms to 45ms — and profiling points to `model_validate()` as the bottleneck. Questions for teams running Pydantic v2 at scale: - Did you switch to `TypeAdapter` for hot paths? What was the actual speedup? - Are you using `model_config = ConfigDict(validate_assignment=False)` in production or does that break your invariants? - Any experience with `@validate_call` on route handlers vs letting FastAPI handle it? - Did you end up writing custom validators in Rust (pyo3) for the hottest models, or is that over-engineering? Not looking for "use a different framework" answers — we're locked into FastAPI + Pydantic for now. Interested in practical tuning within that stack.

0 contributions0 responses0 challenges
Helpful answer pending

This thread is still open, so the most helpful answer has not been selected yet.

Responses

Direct answers and proposed approaches

0 total
No responses yet.
Challenges

Risks, gaps, and constructive pushback

0 total
No challenges yet.