← Questions

Configuration store with subscriber notifications

0
AmazonOO designLast asked Sep 2025

An object-oriented design interview question asked in Amazon's coding round, last asked Sep 2025. It tests object-oriented design and observer pattern.

Design a configuration service: a system sets configuration values, and applications subscribe to the keys or namespaces they care about. When a value changes, every subscriber of that key is told promptly. Start with the classes in one process, then explain how it serves thousands of client applications.

Requirements

  • Functional: set(key, value), get(key), subscribe(key_or_namespace, callback) -> subscription_id, unsubscribe(subscription_id); namespaces such as payments.*; every change versioned, with rollback to an earlier version; access control on who may read and write which keys.
  • Non-functional: subscribers notified within seconds; a clear delivery guarantee (at least once, in version order per key); thread-safe; durable (a restart loses no values); scales to thousands of clients.

Clarifying questions

  • Is this a library inside one process, or a networked service?
  • Must notifications arrive in order? Is at-least-once acceptable, with duplicates?
  • If a value changes many times a second, should subscribers see every change or only the latest?
  • What happens when a subscriber's callback throws or is slow?

What a strong answer covers

  • Classes: ConfigStore (key to a list of ConfigVersion(value, version, author, time)), SubscriptionRegistry (exact keys and namespace prefixes to subscriber lists, for example a trie for prefixes), Notifier (delivers changes), and Subscriber or callback objects.
  • Notification order and semantics: a monotonically increasing version per key, delivered in version order; at-least-once with the version so subscribers can drop duplicates; optional debouncing that sends only the latest value.
  • Thread safety: a lock or copy-on-write map for values, a snapshot of the subscriber list taken before notifying, and callbacks run outside the lock on a separate executor so a slow subscriber cannot block set.
  • Rollback as a new version that copies an old value, so history stays append-only.
  • Partial failure: a failing callback retried or logged without stopping the others.
  • At scale: persistence in a replicated store, clients holding a local cache and receiving changes over long polling or WebSockets (with the trade-off), fan-out through a pub/sub layer, and clients that reconnect by asking for changes since their last version.
  • Complexity: get O(1); set O(subscribers of the key plus matching prefixes).

Follow-ups

  • A bad configuration value is pushed and breaks clients. How do you roll it out gradually and roll it back fast?
  • A client was offline for an hour. How does it catch up?
  • How do you keep two related keys consistent when they change together?

Where it's asked

  • Amazon · Coding · Last asked Sep 202555 min · Usually two rounds; one is often an object-oriented design built in steps · No AI

What it tests

object-oriented design · observer pattern

Your canvas
Draw your answer hereBoxes, arrows and notes, saved for you to come back to.Sign in to start drawing