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 →
← CoursesSystem Design for Python JuniorsModule 6 · Real-World System Design CasesDesign URL shortener: capacity math firstwrite81 / 105
+120 XP
Task
📝 **Task:** Build a small \`dead_letter_handler(msg, retry_count, max_retries)\` that returns one of \`"retry"\`, \`"deadletter"\`, or \`"drop"\`: 1. \`msg.get("malformed", False) is True\` → \`"drop"\` (never retry corrupt input — it'll fail forever). 2. \`retry_count < max_retries\` → \`"retry"\` (still under the budget). 3. \`retry_count == max_retries\` → \`"deadletter"\` (used up the budget — route to DLQ for ops review). 4. \`retry_count > max_retries\` → \`"drop"\` (already DLQ'd; subsequent failures drop silently to stop noise). This pattern is what protects every production queue from poison-message storms. 📋 Implement the function above. Tests run automatically. 💡 **Hint:** Re-read the theory if you get 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…