Byte-Bounded LRU Cache for Container Image Layers With Pinning

Last updated: November 29, 2026

Quick Overview

Design a node-local cache of container image layers bounded by total bytes, with get, put, pin and unpin, where layers in use by running containers are pinned and must never be evicted.

Coreweave
Coding & Algorithms
Software Engineer
Coreweave
November 29, 2026
Software Engineer
Onsite
Coding & Algorithms
Medium

0

0

0 solved


Design a node-local cache of container image layers bounded by total bytes, with get, put, pin and unpin, where layers in use by running containers are pinned and must never be evicted.

Relevant to fast pod start on GPU nodes, where multi-gigabyte CUDA and framework images dominate cold-start time and NVMe space is shared with customer scratch data. The interviewer looks for O(1) operations, correct handling of pinned bytes, and sensible behavior when an item cannot fit.

What the Interviewer Expects
  • Evicts by bytes, not item count
  • Keeps pinned layers out of the eviction order so eviction stays O(1) amortized
  • Supports reference-counted pins
  • Refuses an insert that cannot fit without pointlessly evicting others
  • Re-inserts unpinned layers as most recently used
Key Topics to Cover
LRU cache
OrderedDict
Reference counting
Container images
Cache eviction
How to Approach This
  1. Clarify input constraints and edge cases before writing code.
  2. Walk through your approach verbally and confirm with the interviewer before coding.
  3. Start with a brute force solution, then optimize. Mention time and space complexity.
  4. Test your solution with examples, including edge cases like empty input or duplicates.
  5. Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
  • How would you prefetch layers for a job that is queued but not yet scheduled?
  • Layers are shared across images; how does deduplication change accounting?
  • How would you make eviction aware of layer popularity across the fleet rather than only local recency?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice DSA Problems
Sample Answer
Requirements

Capacity in bytes. put(digest, size) caches a layer, evicting least recently used unpinned layers as needed, and returns False if it cannot fit. get returns whether the layer is cached and refresh...

High-Level Design

Two maps: an OrderedDict of unpinned layers in recency order (oldest first) and a dict of pinned layers with [size, count]. Pinning moves a layer out of the LRU so eviction never has to skip over ...


Submit Your Answer
Markdown supported

Related Questions