System Design AI

Design a Notification Service: The Junior, Senior and Staff Answer

When an interviewer asks you to design a notification service, they want to see how you translate a simple product idea into a system that can handle real-world traffic. They look for your ability to pick the right building blocks, reason about capacity, and anticipate failure modes. Below we walk through the three answer levels you might give, the numbers that drive the design, and the concrete AWS services that fit each part.

What the interviewer is testing

  • Scalability – can you estimate load and grow the system?
  • Data modeling – do you choose the right store for user preferences and message state?
  • Reliability – how do you guarantee delivery or graceful degradation?
  • Operational thinking – do you think about monitoring, cost, and incident response?

Core requirements and driving numbers

RequirementTypical value (hedged)
Peak notifications per secondRoughly 10 k msg/s (≈864 M per day)
Active users receiving notificationsOn the order of 10 M
Latency target< 200 ms for most channels
Delivery guaranteesAt-least-once for email/SMS, best-effort for push

These numbers let you size queues, databases, and compute. For example, 10 k msg/s means a single SQS queue can comfortably handle the load (it scales to millions of requests per second), but you may need multiple partitions for Kafka on MSK if you want ordering per user.

Core design in prose – request path hop by hop

  1. API layer – A thin Amazon API Gateway + Lambda (or an EC2/ALB pair) receives a POST request with user ID, channel type, and payload. The Lambda validates the request and writes a record to a durable store.
  2. Persist user preferences – DynamoDB holds a table keyed by UserID. Each item stores a list of enabled channels (email, SMS, push) and per-channel throttling limits. DynamoDB is chosen over Aurora because we need low-latency key-value lookups and can tolerate eventual consistency for preferences.
  3. Queue the notification – The Lambda pushes a message onto an Amazon SQS standard queue. SQS gives at-least-once delivery and automatic scaling. For ordered delivery per user, you could use a FIFO queue or Kafka on MSK with a partition key of UserID.
  4. Worker pool – An Auto Scaling group of EC2 instances (or Fargate tasks) pulls messages from the queue. Each worker reads the user’s preference from DynamoDB, then routes the payload to the appropriate channel.
  5. Channel adapters –
  • Email – Amazon SES
  • SMS – Amazon SNS (or a third-party provider via HTTP)
  • Push – Amazon SNS mobile push or a custom WebSocket service backed by ElastiCache (Redis) for low-latency fan-out.
  1. Result store – After a successful send, the worker writes a delivery record to a DynamoDB "SentLog" table. This table can be later queried for analytics.
  2. Metrics & alerts – CloudWatch collects queue depth, Lambda errors, and worker CPU. Alarms trigger a SNS alert to the on-call page.

Data model snapshot

SQL
UserPrefs (PK=UserID)
 - emailEnabled BOOL
 - smsEnabled BOOL
 - pushEnabled BOOL
 - dailyQuota INT

SentLog (PK=MessageID)
 - userId
 - channel
 - status
 - timestamp

The choice of DynamoDB over a relational store is driven by the need for single-digit millisecond reads and writes at massive scale. Aurora would add latency and operational overhead for a pattern that is essentially a key-value lookup.

What a complete junior answer covers

  • Lists the basic flow (API → queue → worker → channel).
  • Mentions DynamoDB for preferences and SQS for queuing.
  • Provides a simple capacity estimate (e.g., 10 k msg/s → 864 M/day).
  • Shows a diagram with one request path.
  • Acknowledges eventual consistency and at-least-once delivery.
  • Touches on monitoring with CloudWatch.

What a senior answer adds

  • Sharding – Uses multiple SQS queues or Kafka partitions to spread load and preserve ordering per user.
  • Caching – Adds ElastiCache (Redis) for hot user preference reads, reducing DynamoDB read-through.
  • Rate limiting – Implements a token bucket stored in Redis to enforce per-user daily quotas.
  • Back-pressure handling – Shows dead-letter queues for failed messages and a retry policy.
  • Partial failure handling – Explains how to continue sending other channels if one fails.
  • Cost awareness – Rough estimate of DynamoDB RCUs/WCUs vs. Aurora cost at the given scale.

What a staff answer adds

  • Failure modes – Detailed analysis of each component’s failure (e.g., DynamoDB throttling, SQS throttling, worker crashes) and mitigation (circuit breakers, fallback to S3 for bulk storage of unsent messages).
  • Operational concerns – Deployment pipelines (CodePipeline), blue-green releases, chaos testing, and runbooks for queue backlog spikes.
  • Cost breakdown – Calculates approximate monthly spend: SQS requests (10 k msg/s × $0.40 per million ≈ $10k), DynamoDB read/write capacity (on-demand, billed per million requests, with writes costing several times more than reads), EC2 worker fleet (e.g., 10 c5.large instances ≈ $600 at on-demand rates). Shows how scaling policies keep cost proportional to traffic.
  • Trade-off defense – Justifies at-least-once delivery over exactly-once for email/SMS, argues for eventual consistency on preferences, and explains why a FIFO queue is not used for all traffic (throughput limits).
  • Observability – Adds distributed tracing with AWS X-Ray, structured logs in CloudWatch Logs, and a dashboard in CloudWatch Metrics.
  • Security – Mentions IAM least-privilege roles, KMS encryption for payloads at rest, and VPC endpoints for private SQS access.

Common mistakes that sink this question

MistakeWhy it hurts
Ignoring scale numbersYou cannot justify component choices without traffic estimates.
Choosing a relational DB for preferencesAdds latency and unnecessary complexity for a simple key-value lookup.
Forgetting dead-letter queuesLeads to message loss and no visibility into failures.
Over-engineering ordering for all channelsFIFO queues cap throughput; using them for 10 k msg/s forces unnecessary sharding.
Not addressing delivery guaranteesInterviewer expects you to discuss at-least-once vs. exactly-once semantics.

How to practice this

  1. Study the worked design in the System Design AI library. Observe how the board walks through each hop and how notes explain component choices.
  2. Draw your own canvas on the practice board. Replicate the request path, then add one improvement (e.g., a Redis cache) and note the trade-off.
  3. Run the AI coach on your sketch. Review the feedback on missing failure modes or cost considerations, then iterate.

Questions people ask

What traffic should I assume for a notification service?

A safe estimate is around 10 k messages per second, which translates to roughly 864 million messages per day. Adjust up or down based on the product’s user base.

Why use DynamoDB instead of Aurora for user preferences?

DynamoDB offers single-digit millisecond latency for simple key-value reads and writes, scales automatically, and costs less for high-volume, low-complexity data than a relational engine.

When should I choose Kafka on MSK over SQS?

Use Kafka when you need ordered processing per user or need to retain messages for a longer window. SQS is simpler and cheaper for fire-and-forget delivery.

How do I handle a sudden spike that backs up the queue?

Configure a dead-letter queue, enable auto-scaling on the worker fleet, and set CloudWatch alarms on queue depth. In extreme cases, spill excess payloads to S3 for later replay.