Design a Delayed Job Queue for Expiring Instagram Stories
Last updated: November 29, 2026
Quick Overview
Design a delayed-execution service that fires an event exactly when each Instagram Story turns 24 hours old, so it is removed from viewers' trays, moved to the creator's archive, and dropped from caches.
Meta
November 29, 20260
0
0 solved
Design a delayed-execution service that fires an event exactly when each Instagram Story turns 24 hours old, so it is removed from viewers' trays, moved to the creator's archive, and dropped from caches.
Instagram publishes hundreds of millions of stories a day, each with a hard 24-hour lifetime, which makes it a natural delayed job queue question. The interviewer checks whether you avoid a naive full-table scan, choose a timer structure that scales (bucketed time wheel), and pair it with read-time filtering so correctness does not depend only on the timer.
What the Interviewer Expects
- Recognize read-time filtering as the correctness guarantee
- Use time-bucketed storage or a timing wheel for billions of timers
- Fan out expiry side effects to archive, caches and indexes
- Handle backlog after an outage without missing events
- Make handlers idempotent
Key Topics to Cover
How to Approach This
- Start by clarifying functional and non-functional requirements with the interviewer.
- Estimate the scale: QPS, storage, bandwidth. This drives your design decisions.
- Draw a high-level architecture first, then deep dive into 1-2 critical components.
- Discuss trade-offs explicitly (e.g., consistency vs availability, SQL vs NoSQL).
- Address failure scenarios, monitoring, and how the system handles 10x traffic spikes.
Possible Follow-up Questions
- Why not just set a TTL in the database and be done?
- How would you support Close Friends stories or creators who delete early?
- What changes if Highlights let creators keep a story past 24 hours?
- How do you measure that expiry is on time?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice System Design ProblemsSample Answer
Requirements
Functional: when a story is posted at time , schedule an expiry job for . At expiry: remove it from tray rankings and feed caches, move it to the creator's private archive, update coun...
High-Level Design
Two layers. Correctness at read time: the tray and story viewer filter out any story with created_at < now - 24h, so a late timer never shows an expired story. **Side effects via a delay queue:*...