Design a prioritized log manager with eviction
GoogleSoftware Engineer · Technical ScreenLast updated
Design a prioritized log manager with eviction evaluates requirements, scale assumptions, API/data design, architecture, trade-offs, failure modes, and rollout in a realistic interview setting. A strong answer states assumptions, handles edge cases, explains trade-offs, and shows how to validate the result clearly.
Design a log management component that supports prioritized deletion under capacity constraints. Requirements: (
- The total number of stored log records across all files must not exceed total_max. (
- addLog(fileId, record, priority, timestamp) must automatically evict old data when limits are exceeded. (
- When eviction is required, delete the "least important" logs first according to a well-defined policy that considers priority (higher is more important) and recency (newer is more important). (
- Support both per-file limits (optional X per file) and a global limit total_max. (
- Provide APIs to add logs, query by file, and observe current capacities. Target complexities: O(
- or amortized O(
- to identify a deletion candidate and O(log n) or better per insertion/eviction. Describe your data model, data structures, and trade-offs.
Solution walkthrough is for members
Get the full walkthrough with reference code and complexity analysis, plus Kitty Coach at 300 messages a day. Hints, the code runner and community answers stay free.