Katkat

Design a memory usage switcher with thresholds

AmazonSoftware Engineer · Technical Screen

Last updated

This question evaluates system design and operational engineering skills in process memory management, runtime configurability, observability, and reliability, and belongs to the System Design domain; it primarily tests practical application with system-level conceptual reasoning.

Design an in-process memory usage switcher that monitors current memory consumption and flips the application between NORMAL and DEGRADED modes when usage crosses configurable thresholds. Requirements: support runtime updates to thresholds (e.g., warn at T_warn, shed at T_shed) with hysteresis to prevent flapping; expose APIs (setThresholds, getState, registerCallbacks) and trigger actions on transitions (evict caches, slow batch jobs, reject requests); work across Linux and macOS—compare sampling process RSS, OS memory-pressure notifications, and container/cgroup signals; support multi-tenant budgets where components register their own limits; emit metrics and logs, provide health checks, and ensure safe shutdown; address concurrency and thread safety, failure modes, testing strategy (load tests, fault injection), and configuration persistence and rollback.