Coalescing Publish Subscribe State Database for Switch Agents

Last updated: November 29, 2026

Quick Overview

Implement an in-memory hierarchical state store where agents write and delete paths and other agents subscribe to path prefixes, receiving an initial snapshot and then change notifications that coalesce so a slow subscriber only ever sees the latest value per path.

Arista Networks
Software Engineering Fundamentals
Software Engineer
Arista Networks
November 29, 2026
Software Engineer
Onsite
Software Engineering Fundamentals
Hard

0

0

0 solved


Implement an in-memory hierarchical state store where agents write and delete paths and other agents subscribe to path prefixes, receiving an initial snapshot and then change notifications that coalesce so a slow subscriber only ever sees the latest value per path.

EOS is built around a central state database: each feature agent publishes its state and reacts to other agents' state, which is what lets agents restart independently. This question checks whether you understand state-based (not event-based) pub/sub, why coalescing bounds memory, and how late joiners converge.

What the Interviewer Expects
  • Store state by path and index subscriptions in a prefix trie
  • Give new subscribers a snapshot of current state under their prefix
  • Coalesce pending notifications per path so memory is bounded by state size, not write rate
  • Represent deletes explicitly so subscribers can remove state
  • Suppress no-op writes
Key Topics to Cover
publish subscribe
state synchronization
trie
coalescing
agent architecture
How to Approach This
  1. Apply SOLID principles. Single Responsibility makes code testable, Open/Closed makes it extensible.
  2. Choose data structures based on access patterns, not familiarity.
  3. Prefer immutable data and message passing over shared mutable state for concurrency.
  4. Design APIs with RESTful conventions, versioning, meaningful errors, and pagination from day one.
Possible Follow-up Questions
  • Coalescing hides link flaps. How would a subscriber that needs every transition (a flap counter) get them?
  • How would this work across processes with shared memory, and who owns writes to each path?
  • How does an agent that restarts rebuild its view without the writer replaying history?
  • How do you avoid a subscriber callback writing back and causing an infinite notification loop?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice System Design Problems
Sample Answer
Requirements

set(path, value), delete(path), subscribe(prefix) returning a subscription with poll() that drains (path, value, deleted) tuples. Subscribers must converge to the writer's current state no m...

High-Level Design

The key insight is state-oriented delivery: subscribers care about the current value, not every intermediate event. Each subscription keeps a dict of pending path to latest value; a new write to a pen...


Submit Your Answer
Markdown supported

Related Questions