Skip to main content
🔒 Preview mode. The first 15 Foundations lessons are free; this one is Pro. Start a 7-day trial to unlock the editor, AI hints and the rest of the curriculum. Card required, cancel any time in Dashboard.Start 7-day trial →
← CoursesFastAPI ProductionModule 6 · Real-World PatternsDeployment: gunicorn + uvicorn workerswrite104 / 105
+150 XP
Task
📝 **Task:** Implement `recommend_workers(cpu_cores, kind)` returning `2*cpu_cores + 1` for `'sync'` and `2*cpu_cores` for `'async'`, with a floor of 1. Then implement `recycle_targets(n_workers, max_requests, jitter, rand)` returning a list of per-worker recycle points `max_requests + rand()` where `rand()` yields a fresh integer 0..jitter for each worker. The script calls both with deterministic inputs. 📋 Implement the function above. Tests run automatically. 💡 **Hint:** Re-read the theory if stuck.
✏️ Write your code here
🐍
Loading Python...
One-time download (~1 MB). Then it runs instantly.
📊 Result
Press Run to see result...

💬 Discussion

Be the first to ask a question or share a tip.
Sign in to join the discussion. Reading is free.
Loading discussion…