Final Project — Production-Grade Task Manager API¶
🎯 Learning Goals¶
By the end of this lesson, you will be able to:
- Deploy your FastAPI Task Manager API to a cloud provider.
- Configure monitoring and scaling for production workloads.
- Review the full architecture and plan next steps for extending your project.
⚡ Step 1: Deploy to the Cloud¶
You’ve already containerized your app with Docker and set up CI/CD. Now you’ll deploy it.
Option A: Render¶
- Push your code to GitHub.
- Create a new Web Service in Render.
-
Connect your repo and set the build command:
docker build -t fastapi-taskmanager . -
Render automatically deploys on every push.
Option B: Fly.io¶
-
Install Fly CLI:
curl -L https://fly.io/install.sh | sh -
Initialize app:
fly launch -
Deploy:
fly deploy
Option C: AWS ECS (Elastic Container Service)¶
- Push Docker image to Amazon ECR.
- Create ECS service with Fargate.
- Configure load balancer and auto-scaling.
⚡ Step 2: Monitor and Scale¶
Logging¶
- Use structured logging (JSON) and ship logs to CloudWatch (AWS), Loki (Grafana), or ELK stack.
Metrics¶
- Expose
/metricswithprometheus-fastapi-instrumentator. - Scrape with Prometheus, visualize in Grafana.
- Track request rate, latency, error rate, and task creation counts.
Tracing¶
- Use OpenTelemetry to trace requests.
- Export spans to Jaeger or Tempo for distributed tracing.
Scaling¶
- Horizontal scaling: run multiple Gunicorn workers or replicas.
- Vertical scaling: increase CPU/memory for heavy workloads.
- Cloud auto-scaling: configure rules (e.g., scale up when CPU > 70%).
⚡ Step 3: Final Review¶
Your production-grade Task Manager API now includes:
- ✅ Authentication & Authorization (JWT, admin-only endpoints)
- ✅ Task Management (per-user ownership, CRUD)
- ✅ Background Tasks (notifications, logging)
- ✅ WebSockets (real-time updates)
- ✅ Testing (unit + integration with pytest & TestClient)
- ✅ Deployment (Docker + Gunicorn/Uvicorn workers)
- ✅ CI/CD (GitHub Actions for tests + Docker builds)
- ✅ Monitoring (logging, metrics, tracing with Prometheus/Grafana)
- ✅ Scaling (cloud auto-scaling, load balancing)
⚡ Step 4: Next Steps¶
- Add a frontend: Build a React or Vue dashboard that consumes your API and listens to WebSocket updates.
- Enhance notifications: Integrate with real email/SMS providers (SendGrid, Twilio).
- Role-based access control (RBAC): Add more granular permissions.
- Database migrations: Use Alembic for schema evolution.
- Security hardening: Add HTTPS, rate limiting, and audit logs.
- Deploy globally: Use CDNs and multi-region deployments for low latency.
🧪 Practice Challenge¶
- Deploy your Task Manager API to Render or Fly.io.
- Configure Prometheus + Grafana to monitor request rate and error rate.
- Simulate load (e.g., with
locustorab) and watch your app auto-scale. - Tag your release as
v1.0.0and push to GitHub to trigger CI/CD.
🧠 Recap¶
In this final project, you:
- Deployed your FastAPI app to the cloud.
- Configured monitoring and scaling for production.
- Reviewed the full architecture of a production-grade Task Manager API.
- Planned next steps to extend and harden your system.