Bounded Store And Forward Buffer For An Edge Gateway
Last updated: November 29, 2026
Quick Overview
Implement a thread-safe, byte-bounded outbox for an edge gateway that buffers telemetry and alarms while the cloud link is down, evicts oldest telemetry before any alarm when full, and only removes messages once the cloud acknowledges them.
Schneider Electric
November 29, 20260
0
0 solved
Implement a thread-safe, byte-bounded outbox for an edge gateway that buffers telemetry and alarms while the cloud link is down, evicts oldest telemetry before any alarm when full, and only removes messages once the cloud acknowledges them.
EcoStruxure edge gateways at sites with flaky connectivity must keep data until the uplink returns without running out of memory. The interviewer checks concurrency basics, a clear eviction policy, and at-least-once delivery semantics with ack and retry.
What the Interviewer Expects
- Bounds memory by bytes, not message count
- Evicts oldest telemetry before alarms
- Keeps in-flight messages until acked and requeues on nack
- Protects shared state with a lock
- Explains at-least-once delivery and the need for idempotent ingestion
Key Topics to Cover
How to Approach This
- Apply SOLID principles. Single Responsibility makes code testable, Open/Closed makes it extensible.
- Choose data structures based on access patterns, not familiarity.
- Prefer immutable data and message passing over shared mutable state for concurrency.
- Design APIs with RESTful conventions, versioning, meaningful errors, and pagination from day one.
Possible Follow-up Questions
- How would you persist the buffer to flash so a power cycle does not lose alarms, and how do you limit flash wear?
- Should in-flight bytes count against the cap? What happens if they do not?
- How would you downsample old telemetry instead of dropping it?
- How do you add a blocking consumer with a timeout?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice System Design ProblemsSample Answer
Requirements
put(payload, priority), next_batch(n) for the uplink thread, ack(ids) and nack(ids). Capacity is total bytes including in-flight messages, since those are still in RAM. Alarms are sent first a...
High-Level Design
Two OrderedDicts keyed by a monotonically increasing id, one per priority, plus an in_flight dict. put evicts from the head of telemetry, then alarms, until the new message fits. In-flight messa...