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 CDN cache invalidationpredict94 / 105
+100 XP
Task
📝 **Task:** Predict the printed line `ttl=<stale> purge=<stale> versioned=<stale>` for the three strategies. 📋 Implement the function above. Tests run automatically. 💡 **Hint:** Re-read the theory if stuck.
Predict the output

Read the code carefully

TTL_HOURS = 6
DEPLOYS = 1000
DEPLOYS_PER_DAY = 4
USERS_PER_HOUR = 100             # baseline traffic
PURGE_SUCCESS_PCT = 95           # purge API misses 5% of edge nodes

# TTL: users hitting cache during the stale window between deploy and TTL expiry
ttl_stale = DEPLOYS * (TTL_HOURS * USERS_PER_HOUR)
# Purge: 5% of edges miss the purge -> stale until TTL
purge_stale = DEPLOYS * (TTL_HOURS * USERS_PER_HOUR) * (100 - PURGE_SUCCESS_PCT) // 100
# Versioned URLs: new URL per deploy, no stale exposure ever
versioned_stale = 0
print(f"ttl={ttl_stale} purge={purge_stale} versioned={versioned_stale}")

What will the program print? Write here:

💬 Discussion

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