Katkat

Design an In-Memory Pub-Sub Model

AmazonSoftware Engineer · Technical Screen

Last updated

This question evaluates object-oriented design and API modeling skills, knowledge of messaging/pub-sub semantics, concurrency and thread-safety, and the ability to reason about extensibility for retries, persistence, and asynchronous delivery.

Design an object-oriented, in-memory publish-subscribe model.

Requirements:

  • A publisher can publish a message to a topic.
  • A subscriber can subscribe to or unsubscribe from a topic.
  • When a message is published to a topic, all current subscribers of that topic should receive the message.
  • The design should support multiple topics and multiple subscribers.
  • Define the main classes, interfaces, and public APIs.
  • Explain the delivery behavior, thread-safety considerations, and how you would extend the design for retries, persistence, or asynchronous delivery.