Katkat

Design a prioritized log manager with eviction

GoogleSoftware Engineer · Technical Screen

Last 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: (

  1. The total number of stored log records across all files must not exceed total_max. (
  2. addLog(fileId, record, priority, timestamp) must automatically evict old data when limits are exceeded. (
  3. 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). (
  4. Support both per-file limits (optional X per file) and a global limit total_max. (
  5. Provide APIs to add logs, query by file, and observe current capacities. Target complexities: O(
  6. or amortized O(
  7. to identify a deletion candidate and O(log n) or better per insertion/eviction. Describe your data model, data structures, and trade-offs.