← Amazon Interview Insights

Amazon·Software Engineer·Onsite - System Design / Architecture·Senior

SeniorPrefer not to say
May 2026

Summary

Amazon SWE system design round focused entirely on building an in-process pub-sub broker from scratch. The depth of follow-ups on concurrency and delivery semantics made it feel more like a senior design interview than a typical coding screen.

Questions Asked (5)

Q1

Design an in-process publish/subscribe messaging system supporting multiple topics, multiple subscribers per topic, and a subscriber registered on more than one topic.

System DesignTechnical Trade-offs
Author's notes

I started with the class structure: a Broker holding a map of topic to subscriber sets, a Subscriber interface with an onMessage callback, and Topic as a string wrapper.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying requirements and scale, then define the core abstractions (Topic, Subscriber, Broker) and the registration/delivery semantics. Walk through the data structures and concurrency model, and discuss trade-offs like synchronous vs asynchronous delivery and backpressure.

Pro tip: Emphasize thread-safety and lock granularity early, and mention how you'd handle a slow subscriber without blocking others—this shows production maturity beyond basic pub/sub.

1. Clarify Requirements and Scope

Ask about expected scale, delivery guarantees (at-most-once, at-least-once), ordering, and whether subscribers can register/unregister dynamically. Confirm in-process constraints and performance goals.

2. Define Core Abstractions and API

Outline interfaces for Topic, Subscriber, and Broker with methods like subscribe, unsubscribe, publish, and a callback or queue for delivery. Specify that a subscriber can be registered to multiple topics.

3. Design Data Structures and Concurrency

Propose a thread-safe registry mapping topics to subscriber lists (e.g., ConcurrentHashMap with CopyOnWriteArrayList or fine-grained locks). Explain how to avoid blocking publishers and ensure safe concurrent access.

4. Choose Delivery Model and Handle Edge Cases

Decide between synchronous callbacks and asynchronous queues per subscriber. Discuss backpressure, slow subscribers, and error isolation so one failure doesn't affect others.

5. Discuss Trade-offs and Extensions

Compare design choices (e.g., lock-free vs locking, direct dispatch vs executor) and mention potential extensions like filtering, wildcards, or persistence if needed.

Key Points to Mention

  • Thread-safe subscriber registry with fine-grained locking or concurrent collections
  • Support for multiple topics per subscriber and dynamic subscribe/unsubscribe
  • Delivery semantics: synchronous vs asynchronous, and ordering guarantees
  • Backpressure and slow subscriber handling (e.g., bounded queues, drop policies)
  • Error isolation so one subscriber's failure doesn't impact others
  • Trade-offs between simplicity, performance, and scalability in an in-process context

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.

Q2

How would you handle concurrency when publishers and subscribers run on separate threads? Walk through your locking strategy.

System DesignTechnical Trade-offs
Author's notes

This is where things got interesting.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the system's requirements and constraints, such as throughput, latency, and consistency needs. Then, propose a locking strategy that balances correctness and performance, explaining trade-offs and alternatives like lock-free structures. Finally, walk through a concrete example to illustrate your approach.

Pro tip: Demonstrate awareness of Amazon's leadership principles by emphasizing customer obsession (e.g., choosing a strategy that minimizes latency for end-users) and ownership (e.g., considering failure modes and operational simplicity).

1. Clarify Requirements

Ask about expected throughput, latency sensitivity, consistency requirements, and whether publishers/subscribers are internal or external. This ensures your solution aligns with business needs.

2. Identify Shared State

Determine what data is shared between publishers and subscribers, such as a message queue or topic registry. This helps pinpoint where synchronization is needed.

3. Choose a Locking Strategy

Propose a locking approach (e.g., fine-grained locks, read-write locks, or lock-free structures) based on requirements. Explain why it fits and mention alternatives.

4. Address Potential Issues

Discuss deadlocks, contention, and scalability. Explain how you'd mitigate them, such as lock ordering, backoff, or partitioning.

5. Illustrate with an Example

Walk through a concrete scenario, like a pub/sub system with a shared queue, showing how locks are acquired and released to ensure thread safety.

Key Points to Mention

  • Trade-offs between coarse-grained and fine-grained locking
  • Use of read-write locks for read-heavy workloads
  • Lock-free or wait-free data structures (e.g., concurrent queues)
  • Deadlock prevention techniques (e.g., lock ordering, timeouts)
  • Performance considerations: contention, scalability, and latency
  • Amazon Leadership Principles: Customer Obsession, Ownership, and Dive Deep

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.

Q3

What delivery semantics does your broker provide, and what happens if a subscriber's callback throws an exception during message delivery?

System DesignTechnical Trade-offs
Author's notes

I went with at-most-once first since it's simpler: fire the callback, if it throws you log and move on.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the delivery semantics your broker supports (at-most-once, at-least-once, exactly-once) and the trade-offs involved. Then explain the exception handling behavior, including retries, dead-letter queues, and idempotency, and tie it back to Amazon's customer-obsessed, ownership-driven culture.

Pro tip: Emphasize that you design for failure: assume callbacks will throw and build idempotent consumers with dead-letter queues and monitoring. This shows you think beyond the happy path and align with Amazon's operational excellence.

1. Define delivery semantics

State the broker's delivery guarantee (e.g., at-least-once) and explain what that means for message duplication or loss. Mention how it's configured and any trade-offs.

2. Describe exception handling

Explain what happens when a subscriber callback throws: does the broker retry, nack, or drop the message? Detail retry policies, backoff, and max attempts.

3. Cover dead-letter queues and failure isolation

Describe how failed messages are routed to a DLQ after retries, and how this prevents poison messages from blocking the queue.

4. Address idempotency and ordering

Explain how consumers handle duplicates (idempotent processing) and whether ordering is preserved, especially with retries.

5. Tie to operational excellence

Mention monitoring, alerting, and metrics for failed deliveries, and how you'd debug and improve the system over time.

Key Points to Mention

  • At-least-once vs. at-most-once vs. exactly-once semantics and their trade-offs
  • Retry policies with exponential backoff and maximum retry limits
  • Dead-letter queues (DLQ) for poison messages and manual intervention
  • Idempotent consumer design to handle duplicate deliveries
  • Message ordering guarantees and how retries affect them
  • Monitoring and alerting on delivery failures and DLQ depth

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.

Q4

How do you prevent a slow subscriber from causing memory to grow unboundedly in the broker?

System DesignTechnical Trade-offs
Author's notes

Talked about per-subscriber bounded queues with a drop or block policy, and async dispatch through a thread pool so a slow consumer doesn't stall the publish call.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the scenario and requirements (e.g., message delivery guarantees, subscriber types). Then discuss a layered strategy: backpressure, bounded queues, and flow control, while highlighting trade-offs between durability, latency, and resource usage. Conclude with monitoring and dynamic adjustments to handle edge cases.

Pro tip: Emphasize that the goal is not to avoid dropping messages but to make intentional, observable decisions about which messages to drop or delay, and to communicate those decisions to subscribers. This shows you understand real-world constraints and customer impact.

1. Clarify requirements and constraints

Ask about delivery guarantees (at-least-once, exactly-once), subscriber types (push vs pull), and acceptable latency. This sets the context for trade-offs.

2. Implement backpressure and flow control

Describe mechanisms like TCP flow control, pull-based consumption, or explicit credit-based flow control to let the broker signal the subscriber to slow down.

3. Use bounded queues with overflow policies

Explain how to set per-subscriber queue limits and define policies: drop oldest, drop newest, or spill to disk. Discuss the impact on message loss and ordering.

4. Monitor and adapt dynamically

Mention metrics (queue depth, consumer lag) and automated actions like throttling, disconnecting slow subscribers, or scaling out. Highlight the need for alerts and dashboards.

5. Discuss trade-offs and alternatives

Compare approaches: e.g., dropping messages vs. blocking producers vs. persisting to disk. Tie back to business requirements and Amazon leadership principles like Customer Obsession.

Key Points to Mention

  • Backpressure mechanisms (e.g., TCP windowing, pull-based consumption, credit-based flow control)
  • Bounded queues with configurable limits and overflow policies (drop oldest/newest, spill to disk)
  • Monitoring and metrics (queue depth, consumer lag, throughput) with automated remediation
  • Trade-offs between durability, latency, and resource usage (e.g., dropping messages vs. blocking producers)
  • Amazon-specific services (SQS, Kinesis, MSK) and their built-in flow control features
  • Handling edge cases: subscriber disconnection, slow network, and poison messages

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.

Q5

Can you extend this design to support per-subscription priority, where higher-priority subscribers receive a message before lower-priority ones?

System DesignData Modeling
Author's notes

Swapping the subscriber set for a sorted structure keyed on priority.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the requirements: what defines priority, how many levels, and whether strict ordering is needed. Then propose a design that separates messages into priority queues, using a broker or database with priority support, and discuss trade-offs like starvation and scalability.

Pro tip: Mention that Amazon often uses SQS with multiple queues per priority and a consumer that polls higher-priority queues first, but be prepared to discuss how to avoid starving low-priority messages.

1. Clarify requirements

Ask about priority levels, whether strict ordering is required, and the expected volume and latency. This ensures the design meets actual needs.

2. Choose a data model

Decide how to store priority with each message, e.g., a priority field in the message metadata or separate queues per priority level.

3. Design the delivery mechanism

Propose a system where consumers fetch from higher-priority queues first, or use a priority queue data structure. Discuss how to handle concurrency and ordering.

4. Address trade-offs and edge cases

Discuss starvation of low-priority messages, fairness, scalability, and failure scenarios. Suggest mitigation like aging or weighted round-robin.

5. Summarize and validate

Recap the design, highlight how it meets requirements, and invite feedback or further questions.

Key Points to Mention

  • Priority levels and their definitions
  • Use of multiple queues or a priority queue data structure
  • Consumer polling strategy (e.g., weighted or strict priority)
  • Starvation prevention techniques (aging, quotas)
  • Scalability and fault tolerance considerations
  • Trade-offs between strict ordering and throughput

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.