Design an On-Device Image Cache and Prefetcher for the Instagram App
Last updated: November 29, 2026
Quick Overview
Design the client-side image cache for the Instagram mobile app, including memory and disk tiers, prefetching images just ahead of the scroll position in feed, and eviction under tight storage limits.
Meta
November 29, 20260
0
0 solved
Design the client-side image cache for the Instagram mobile app, including memory and disk tiers, prefetching images just ahead of the scroll position in feed, and eviction under tight storage limits.
Meta mobile engineers own a lot of performance work on device, and smooth feed scrolling depends on images being ready before they enter the screen. The interviewer checks a sensible two-tier cache, bounded prefetch, decoding off the main thread, and respecting low-end device limits.
What the Interviewer Expects
- Describe memory and disk cache tiers and what each stores
- Prefetch the next few items based on scroll velocity
- Bound cache sizes and choose eviction
- Decode and downsample off the main thread
- Cancel work for items scrolled past
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
- How should the cache behave on a low-memory Android device?
- Would you cache decoded bitmaps or compressed bytes on disk?
- How do you avoid wasting data on users with metered plans?
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
- Feed shows photos and video thumbnails; images should be visible immediately when a post scrolls into view.
- Keep memory use within limits (out-of-memory crashes are worse than slow images).
- Disk...
High-Level Design
Components: image pipeline (request, fetch, decode, transform), memory cache of decoded bitmaps sized to a fraction of available app memory, disk cache of compressed bytes keyed by URL wit...