Design in-memory threshold switcher
AmazonSoftware Engineer · Technical ScreenLast updated
This question evaluates a candidate's ability to design memory-aware control systems, covering skills such as hysteresis-based thresholding, dynamic runtime reconfiguration, thread-safe concurrency, low-overhead metric sampling, event-driven state notifications, and handling multi-process and failure edge cases.
Design an in-memory "switcher" component that toggles between ENABLED and DISABLED states based on runtime memory usage with user-configurable thresholds. Requirements: (
- Support separate upper/lower thresholds (hysteresis) to prevent flapping. (
- Allow dynamic reconfiguration at runtime without downtime. (
- Provide thread-safe reads/writes and low-overhead sampling of memory metrics. (
- Expose callbacks or events when state changes. (
- Define behavior under memory spikes, metric polling failures, and multi-process or multi-instance deployments. (
- Describe data structures, APIs, concurrency model, and monitoring/metrics. (
- Discuss testing strategy, performance considerations, and trade-offs of pull vs push metric collection.
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.