Quick comparison
| Area | FastAPI | FastrAPI | Winner |
|---|---|---|---|
| Dependency resolution | Runtime inspect + reflection every request | One-time parsing at decorator → pre-built injection plan | ✅ FastrAPI |
| Fast-path for trivial endpoints | No special case: full kwargs/dependency work always | is_fast_path flag → skip deps, validation, kwargs | ✅ FastrAPI |
| Route lookup speed | Starlette regex router (slows with many routes) | papaya concurrent hashmap → O(1) lookup | ✅ FastrAPI |
| Middleware usability (Python) | @app.middleware often buggy / limited | Clean, working decorator + real execution | ✅ FastrAPI |
| Background tasks reliability | Fire-and-forget, errors usually swallowed | Proper JoinHandle + error logging | ✅ FastrAPI |
| WebSocket implementation | Starlette (solid but heavy) | Custom with bounded channels + clean async pump | ✅ FastrAPI |
| Startup-time error detection | Almost everything deferred to runtime | Full signature + dependency analysis at decorator time | ✅ FastrAPI |
| Concurrency & resource safety | asyncio + threadpool | Native Tokio + Rust memory & thread safety | ✅ FastrAPI |
| Deployment footprint | Heavy (uvicorn + many deps) | Tiny Rust binary + optional Python runtime | ✅ FastrAPI |
| Scaling to 10,000+ routes | Noticeable slowdown | Stays fast thanks to hashmap lookup | ✅ FastrAPI |
| JSON serialization flexibility | Hard to swap (monkey-patch needed) | Trivial to plug orjson / sonic-rs / simdjson | ✅ FastrAPI |
response_model=None + raw Response return | Fully supported | Not yet supported | ❌ FastAPI |
APIRouter + include_router() | Yes, mature ecosystem | Not yet implemented | ❌ FastAPI |
app.mount() / StaticFiles | Yes | Not yet implemented | ❌ FastAPI |
FastrAPI wins on 11 out of 14 comparison points, with 3 features still in development.
Performance benchmarks
Real-world performance comparison using k6 load testing (20 VUs, 30s duration):Throughput
FastrAPI
31,360 requests/sec
FastAPI (16 workers)
3,882 requests/sec
FastAPI (1 worker)
937 requests/sec
Latency comparison
Performance multiplier: FastrAPI is ~33x faster than FastAPI with 1 worker and ~8x faster than FastAPI with 16 workers.
Architectural differences
Dependency resolution
Route lookup
- FastAPI
- FastrAPI
FastAPI uses Starlette’s regex-based router:Impact: Performance degrades as you add more routes.
Async runtime
FastAPI: asyncio + GIL
FastAPI: asyncio + GIL
FastAPI runs on Python’s
asyncio:- Limited by the Global Interpreter Lock (GIL)
- CPU-bound work blocks the event loop
- Concurrency, but not true parallelism
FastrAPI: Tokio + thread pool
FastrAPI: Tokio + thread pool
FastrAPI uses Tokio’s multi-threaded runtime:
- Python handlers run in isolated thread pool
- Tokio provides true multi-threaded parallelism
- Work-stealing for efficient load balancing
- GIL is released between requests
Middleware execution
| Feature | FastAPI | FastrAPI |
|---|---|---|
| Decorator support | Limited, often buggy | Full support with @app.middleware |
| Layer ordering | Not guaranteed | Explicit, documented order |
| Performance | Python-only overhead | Rust layers + Python fallback |
| Built-in options | Basic CORS | CORS, GZip, Sessions, Trusted Host |
Feature compatibility
Supported features
Features with full FastAPI compatibility
- ✅ Decorator syntax (
@app.get,@app.post, etc.) - ✅ Pydantic models for validation
- ✅ Dependency injection with
Depends() - ✅ Path parameters and query parameters
- ✅ Request/response models
- ✅ WebSockets
- ✅ Middleware (CORS, GZip, Sessions, Trusted Host)
- ✅ Background tasks
- ✅ Security utilities (OAuth2, JWT)
- ✅ Multiple response types (JSON, HTML, PlainText, Redirect)
- ✅ OpenAPI/Swagger documentation
Features in development
- ⏳
APIRouter+include_router() - ⏳
app.mount()for static files - ⏳
response_model=Nonewith raw Response returns - ⏳ Lifespan events (
@app.on_startup,@app.on_shutdown) - ⏳ Exception handlers (
@app.exception_handler()) - ⏳ Hot reloading / watchfiles integration
- ⏳ TestClient for testing
- ⏳
app.statefor mutable app-wide state
Migration guide
Switching from FastAPI
Migration is designed to be seamless:Known migration issues
Be aware of these differences:Response models
Response models
FastrAPI doesn’t yet support
response_model=None with raw Response objects:APIRouter
APIRouter
Sub-applications with
APIRouter are not yet supported:Static files
Static files
app.mount() for static file serving is not implemented:When to use FastrAPI
Use FastrAPI when
- You need maximum performance
- You have high request volumes
- You want lower latency
- You’re building a new API
- You don’t need APIRouter or static files
- You want smaller deployment size
Stick with FastAPI if
- You rely heavily on
APIRouter - You need
app.mount()for static files - You use many third-party FastAPI plugins
- Your app uses advanced response model features
- You need hot reloading in development
- You’re not performance-constrained
Future roadmap
FastrAPI is actively closing the feature gap with FastAPI:For the latest updates, check the GitHub repository.