Amazon logo

Amazon Software Engineer System Design Questions

45 practice questions for Amazon Software Engineer interviews

Amazon software engineer interviews cover algorithms, data structures, system design, and coding problems drawn from real interview rounds.

Software Engineer Backend Engineer Frontend Engineer Full Stack Engineer Mobile Engineer Data Engineer Data Scientist ML Engineer DevOps Engineer DevOps Engineer Product Manager SRE Security Engineer Engineering Manager Data Analyst UX/UI Designer QA Engineer

No verified questions yet for Amazon.

system design Medium api design #1

1. Design AWSUsageBilling — a single-account usage billing ledger


Background
Amazon needs to turn metered AWS usage into reproducible bills for a customer account. Model a small, in-memory version of this workflow that prices EC2 and S3 usage, tolerates retried usage events, and preserves previously accepted charges when rate schedules change. This is an interview-sized model, not a specification of actual AWS billing behavior.
Requirements
1. Maintain rate schedules keyed by (meter, region). A meter identifies a specific billable SKU and unit, such as EC2:t3.micro:instance-second or S3:STANDARD:GB-hour. Each rate has an inclusive effective timestamp and an integer price in micro-USD per unit. One USD equals 1,000,000 micro-USD. Rates may be inserted out of chronological order. Repeating an identical rate is a no-op; changing the price at an existing effective timestamp raises ValueError.
2. Accept usage events containing a globally unique event ID within this account, meter, region, timestamp, and positive integer quantity. Select the rate with the greatest effective timestamp not exceeding the usage timestamp. If none exists, raise ValueError without storing the event. Otherwise, freeze the calculated charge at acceptance time; subsequently inserted rates never reprice stored events.
3. Make usage ingestion idempotent. An exact retry of an accepted event returns false, even if the rate schedule has since changed. Reusing its ID with any different payload raises ValueError. A newly accepted event returns true.
4. Produce an invoice for the half-open usage timestamp interval [start, end). Group events by (meter, region), summing quantities and their frozen charges. Sort invoice lines lexicographically by meter, then region. Each line contains meter, region, quantity, and subtotal_micro_usd.
5. Return invoices as {"account_id": string, "lines": list, "total_micro_usd": integer, "total_cents": integer}. Sum exact charges before rounding: total_cents = (total_micro_usd + 5000) // 10000, which rounds nonnegative amounts to the nearest cent with ties upward. An empty interval has no lines and zero totals. Invoice calls do not modify state; start >= end raises ValueError.
Class API
  • AWSUsageBilling(account_id: str) — construct an empty ledger for one account.

  • set_rate(meter: str, region: str, effective_at: int, unit_price_micro_usd: int) -> None — register a rate version using the conflict rules above.

  • record_usage(event_id: str, meter: str, region: str, timestamp: int, quantity: int) -> bool — accept a new event or handle its retry atomically.

  • invoice(start: int, end: int) -> dict[str, object] — return the invoice structure specified above.


Example 1:
Input sequence:
billing = AWSUsageBilling("acct-1")
billing.set_rate("EC2:t3.micro:instance-second", "us-east-1", 0, 7500)
billing.set_rate("S3:STANDARD:GB-hour", "us-east-1", 0, 2000)
billing.record_usage("e1", "EC2:t3.micro:instance-second", "us-east-1", 100, 2)
billing.record_usage("e1", "EC2:t3.micro:instance-second", "us-east-1", 100, 2)
billing.record_usage("e2", "S3:STANDARD:GB-hour", "us-east-1", 110, 5)
billing.invoice(100, 111)

Output: the usage calls return true, false, and true. The invoice is:
{
  "account_id": "acct-1",
  "lines": [
    {"meter": "EC2:t3.micro:instance-second", "region": "us-east-1", "quantity": 2, "subtotal_micro_usd": 15000},
    {"meter": "S3:STANDARD:GB-hour", "region": "us-east-1", "quantity": 5, "subtotal_micro_usd": 10000}
  ],
  "total_micro_usd": 25000,
  "total_cents": 3
}

Explanation: the duplicate event is not charged twice. EC2 costs 2 × 7500 = 15000 micro-USD and S3 costs 5 × 2000 = 10000. The combined charge is 2.5 cents, rounded once to 3 cents.
Constraints
  • At most 100,000 accepted usage events, 1,000 distinct (meter, region) pairs, and 1,000 rate versions per pair.

  • Identifiers are nonempty strings of at most 128 characters. Timestamps are integer UTC epoch seconds in [0, 10^12]; quantities are in [1, 10^9]; prices are in [0, 10^9] micro-USD per unit.

  • Calls are sequential; no persistence, networking, taxes, credits, free tiers, or currency conversion is required. Rejected calls must not partially modify state.

  • The example rates are synthetic. All quantities for a given meter use the same unit.


Example 2 — retroactive rate insertion:
Using a fresh instance, execute:
billing = AWSUsageBilling("acct-2")
billing.set_rate("EC2:t3.micro:instance-second", "us-east-1", 0, 7500)
billing.record_usage("a", "EC2:t3.micro:instance-second", "us-east-1", 120, 2)
billing.set_rate("EC2:t3.micro:instance-second", "us-east-1", 100, 4000)
billing.record_usage("a", "EC2:t3.micro:instance-second", "us-east-1", 120, 2)
billing.record_usage("b", "EC2:t3.micro:instance-second", "us-east-1", 130, 1)
billing.invoice(120, 131)

Output: the usage calls return true, false, and true. The invoice is:
{
  "account_id": "acct-2",
  "lines": [
    {"meter": "EC2:t3.micro:instance-second", "region": "us-east-1", "quantity": 3, "subtotal_micro_usd": 19000}
  ],
  "total_micro_usd": 19000,
  "total_cents": 2
}

Explanation: event a retains its frozen charge of 2 × 7500 = 15000. Event b uses the newly registered rate and costs 1 × 4000 = 4000. Their grouped quantity is 3, but multiplying that quantity by either single rate would be incorrect.
Want to practise this one?
Create a free account to open the full question and practise Amazon questions with AI.
Sign up free
system design Senior messaging #2

2. Design Notification System — Manage User Notifications

Background: Amazon Mobile and Web Services can greatly benefit from an optimized notification system. This system is crucial for enhancing customer experience by managing notifications effectively and ensuring delivery reliability.
Requirements:
1. Create a NotificationSystem class to manage notifications.
2. Allow users to subscribe and unsubscribe to notifications.
3. Enable scheduling notifications for specific times.
4. Provide functionality for sending out notifications to all subscribers.
5. Ensure that notifications can be prioritized based on urgency.
Class API:
  • def __init__(self): return type None, initializes the notification system.

  • def subscribe(self, user_id: str) -> None: return type None, adds user to subscription list.

  • def unsubscribe(self, user_id: str) -> None: return type None, removes user from subscription list.

  • def schedule_notification(self, user_id: str, message: str, send_time: datetime) -> None: return type None, schedules a notification.

  • def send_notifications(self) -> None: return type None, sends out all scheduled notifications.

Example 1:
  • Input sequence: subscribe("user1"); schedule_notification("user1", "Order shipped!", datetime.now())

  • Output: None

  • Explanation: User 'user1' subscribed and a notification scheduled.

Example 2:
  • Input sequence: send_notifications()

  • Output: "Notifications sent to all subscribers."

  • Explanation: Executes sending notifications to all users.

Constraints:
  • The system must handle up to 10000 subscriptions concurrently.

  • Notifications can be sent at most once every minute.
system design Senior api design #3

3. Design BookMyShow — Simple Ticket Booking System

Background: Amazon has a vast range of services, and a user-friendly ticket booking system similar to BookMyShow can enhance their entertainment sector's offerings. This system is critical for managing ticket availability and customer satisfaction.
Requirements:
1. Create a class called TicketBooking that manages shows and tickets.
2. The class must allow adding new shows with specific details (name, time, and total seats).
3. Enable booking of tickets while ensuring only available seats are bookable.
4. Provide a method to view available tickets for each show.
5. Implement a method to cancel a booking.
Class API:
  • def __init__(self): return type None, initializes the booking system.

  • def add_show(self, show_name: str, show_time: str, total_seats: int) -> None: return type None, adds a new show.

  • def book_ticket(self, show_name: str, number_of_seats: int) -> str: return type str, books tickets if available.

  • def cancel_booking(self, show_name: str, number_of_seats: int) -> str: return type str, cancels booked tickets.

  • def available_tickets(self, show_name: str) -> int: return type int, returns remaining tickets.

Example 1:
  • Input sequence: add_show("Spider-Man", "2022-10-01 19:00", 100); book_ticket("Spider-Man", 5); available_tickets("Spider-Man")

  • Output: 95

  • Explanation: 5 tickets booked, 95 remaining.

Example 2:
  • Input sequence: cancel_booking("Spider-Man", 3); book_ticket("Spider-Man", 2)

  • Output: "Successfully booked 2 tickets."

Constraints:
  • The maximum number of shows should not exceed 1000.

  • Each show can have a maximum of 500 seats.

Related Amazon Software Engineer interview prep

Start practicing Amazon questions

Sign up for free to access walkthroughs, AI-generated questions, and more.

Get Started Free