Implement a Single-Node Priority Pub/Sub

Read the full interview experience this question came from →

Quick Overview

This question evaluates understanding of concurrent system design, in-memory publish–subscribe semantics, prioritized delivery ordering, API and data structure selection, and thread-safety within the Software Engineering Fundamentals domain.

Implement a Single-Node Priority Pub/Sub

Company: Amazon

Role: Software Engineer

Category: Software Engineering Fundamentals

Difficulty: medium

Interview Round: Onsite

Implement a simplified in-memory publish-subscribe system that runs on a single machine. The system should support users subscribing to topics with a priority. ### Requirements 1. A user can subscribe to a topic with an integer priority. 2. A user can unsubscribe from a topic. 3. A publisher can publish a message to a topic. 4. When a message is published, it should be delivered to all current subscribers of that topic in descending priority order. 5. If two subscribers have the same priority, deliver to the one who subscribed earlier first. 6. The implementation should be thread-safe enough to support concurrent subscribe, unsubscribe, and publish calls on a single process. Design the classes, main APIs, data structures, and explain the trade-offs.

Overview: This question evaluates understanding of concurrent system design, in-memory publish–subscribe semantics, prioritized delivery ordering, API and data structure selection, and thread-safety within the Software Engineering Fundamentals domain.

Read the full Amazon Software Engineer interview experience this question came from

|Home/Software Engineering Fundamentals/Amazon
Amazon logo
Amazon
Apr 9, 2026
mediumSoftware EngineerOnsiteSoftware Engineering Fundamentals
3
0

Implement a simplified in-memory publish-subscribe system that runs on a single machine.

The system should support users subscribing to topics with a priority.

Requirements

  1. A user can subscribe to a topic with an integer priority.
  2. A user can unsubscribe from a topic.
  3. A publisher can publish a message to a topic.
  4. When a message is published, it should be delivered to all current subscribers of that topic in descending priority order.
  5. If two subscribers have the same priority, deliver to the one who subscribed earlier first.
  6. The implementation should be thread-safe enough to support concurrent subscribe, unsubscribe, and publish calls on a single process.

Design the classes, main APIs, data structures, and explain the trade-offs.

Loading comments...