High-performance asynchronous API built with FastAPI, featuring WebSocket support, Redis caching, and Prometheus monitoring.
- Async/Await throughout for maximum performance
- WebSocket support for real-time bidirectional communication
- Redis caching with automatic expiration
- Batch processing with concurrent execution
- Server-Sent Events for data streaming
- JWT authentication with role-based access
- Prometheus metrics for monitoring
- Docker Compose setup for easy deployment
- 100% type hints for better IDE support
- Comprehensive error handling
- FastAPI - Modern async web framework
- PostgreSQL + AsyncPG - Async database operations
- Redis - Caching and pub/sub
- Celery - Background task processing
- Prometheus - Metrics and monitoring
- Docker - Containerization
- Handles 10,000+ requests/second on single instance
- Sub-100ms response time for cached requests
- Automatic horizontal scaling support
- Connection pooling for database and Redis
- Clone the repository
- Copy
.env.exampleto.env - Run with Docker Compose:
docker-compose up
- Access API at http://localhost:8000
- View docs at http://localhost:8000/docs
POST /api/v1/data/process- Process single itemPOST /api/v1/data/batch- Batch processing (up to 1000 items)GET /api/v1/data/stream- Server-sent events stream
WS /api/v1/ws/{client_id}- Real-time bidirectional communication
GET /metrics- Prometheus metricsGET /api/v1/health- Health check
# Install dependencies
pip install -r requirements.txt
# Run tests
pytest
# Start server
uvicorn app.main:app --reloadRunning 30s test @ http://localhost:8000/api/v1/data/process
12 threads and 400 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 38.42ms 12.31ms 203.44ms 89.23%
Req/Sec 872.34 134.22 1.43k 71.83%
312,453 requests in 30.10s, 43.82MB read
Requests/sec: 10,381.53
Transfer/sec: 1.46MB
- JWT token authentication
- Rate limiting per user
- Input validation with Pydantic
- SQL injection protection
- CORS configuration
MIT