
Module 20 Exercises: The Master's Challenge
Practical exercises to challenge your ability to architect complete systems and defend your design decisions.
Module 20 Exercises: The Master's Challenge
This is the final test of your intuition as an API Architect. There are no "Code Snippets" here—only high-level design problems.
Exercise 1: The Bottleneck Hunter
You have a system with:
- FastAPI App
- PostgreSQL DB
- Celery Worker
- Redis Queue
A user reports that when they upload a file, the status in the UI stays "Pending" for 60 seconds, even though the worker finishes the job in 2 seconds.
- Is the problem in the FastAPI App, the Redis Queue, or the WebSocket notification?
- How would you use Tracing (Module 18) to verify your guess?
Exercise 2: Selecting the Tech Stack
You are building a Real-Time Multiplayer Poker Game API. List the three most important FastAPI features you would use to build this. (Choose from: WebSockets, Background Tasks, Pydantic, SQLModel, OAuth2). Justify your choices.
Exercise 3: Security vs. Speed
A developer suggests removing Password Hashing (Module 16) and JWT Validation (Module 9) to increase the API's speed by 10%.
- How do you respond as an Engineering Lead?
- What is a better way to increase speed by 10% without compromising security? (Hint: Module 15).
Self-Correction / Discussion
Exercise 1 Answer:
- The WebSocket notification is the likely culprit. If the worker finishes in 2s but the UI doesn't update for 60s, the "Push" mechanism is failing or slow.
- You would look at the trace for the "Notification" job in Jaeger. You would see a 58-second gap between the "Task Finished" span and the "WebSocket Push" span.
Exercise 2 Answer:
- WebSockets: Mandatory for real-time game state updates (dealing cards, betting).
- Pydantic: Critical for validating complex betting rules and hand structures.
- OAuth2: Necessary to protect user accounts and balances.
Exercise 3 Answer:
- "Absolutely not. Security is non-negotiable. A data breach is infinitely more expensive than 10% more hardware."
- Implement Caching (Redis) for frequently accessed data or optimize SQL queries (Indexes).
Congratulations on completing the course!
You have mastered the art of building production-grade APIs. We can't wait to see what you build next.