Volume 12 · Chapter 5 — System Design Case Studies
Case Study: Notifications and Statements System
5.1 The Problem and Requirements
Design a system that sends customer notifications (payment confirmations, alerts) and generates and stores statements and documents. Requirements: functionally, react to events (like a payment) by notifying customers through channels (push, email, SMS), and periodically generate statements and store them for years for compliance. Non-functionally, it must handle high volume and bursts (many notifications at once), be reliable (notifications shouldn’t be lost, statements must be retained and immutable), tolerate the notification work happening slightly after the triggering event, and be cost-effective for storing years of documents. The defining characteristics are event-driven reactivity, burst handling, and long-term compliant document storage.
5.2 High-Level Architecture
The system is event-driven. Business events (a payment made, an alert condition) are published and consumed by a notification service that determines recipients and channels and sends messages, buffered through queues so bursts are absorbed and delivery is reliable and retryable. Statement generation runs as scheduled/asynchronous work - often serverless functions triggered on a schedule - producing documents stored in S3 with lifecycle tiering and object lock for immutable, cost-effective, compliant retention. This is a naturally asynchronous, event-driven, serverless-friendly workload - exactly the kind that benefits from queues, pub/sub, and event-driven processing rather than synchronous request/response.
flowchart TB Ev[(Events: PaymentMade, Alert)] --> Topic[(SNS / EventBridge)] Topic --> Q[(SQS - buffer bursts)] Q --> Notif[Notification service] Notif --> Ch[Push / Email / SMS channels] Q -. repeated failures .-> DLQ[(Dead-letter queue)] Sched[Scheduled event] --> Gen[Statement generator - Lambda] Gen --> S3[(S3 - lifecycle tiering + object lock)]
5.3 Event-Driven and Burst Handling
Notifications are triggered by events, which decouples them from the systems that produce those events - the payment system just publishes “PaymentMade” and the notification service reacts, so notification work never blocks or affects payments. Bursts (a flood of notifications after a batch event) are absorbed by queues that buffer the load while consumers process at a sustainable rate, scaling consumers to the queue depth - so a spike doesn’t overwhelm the channels or downstream providers. Delivery is made reliable through the queue’s durability and retries, with a dead-letter queue capturing messages that fail repeatedly for investigation. Consumers are idempotent so a redelivered event doesn’t send a duplicate notification. This is a textbook application of event-driven, queue-based asynchronous processing for reactive, bursty work.
5.4 Serverless Fit
This workload fits serverless (Lambda) especially well. Notification handling and statement generation are event-driven and often spiky or intermittent - a notification function triggered per event, a statement function triggered on a schedule - so Lambda’s automatic scaling and zero idle cost are ideal: it scales to the burst and costs nothing between events, with no servers to manage. Statement generation is a periodic batch that serverless handles cleanly. Compared with running always-on servers for intermittent notification and periodic statement work, serverless removes both idle cost and operational overhead. This case illustrates when to reach for serverless - event-driven, variable, intermittent work - versus the steady, latency-critical payment path that uses containers.
5.5 Compliant Document Storage and Trade-Offs
Statements and documents are stored in S3 with the practices from the storage volume: lifecycle policies move aging statements to cheaper storage classes automatically (most are old and rarely read but must be retained for years), object lock makes them immutable for the required retention period (compliance demands tamper-proof records), encryption protects them, and versioning guards against accidental loss. This keeps years of compliance documents affordable, immutable, and secure. The main trade-offs: notifications are eventually consistent with the triggering event (accepted - a confirmation arriving moments after the payment is fine), and the system relies on at-least-once delivery with idempotent consumers (so occasional redelivery is handled rather than guaranteeing exactly-once at the messaging layer). The design prioritizes reliability and cost-effectiveness over strict timing.
5.6 Banking Production Notes
In production, this system reliably notifies customers of payments and alerts, absorbing bursts through queues and scaling serverless handlers, and generates and retains statements immutably and cheaply for compliance. It reacts to events from the payment system without ever affecting it, demonstrating the decoupling benefit of event-driven architecture - the notification and statement work is entirely downstream and asynchronous. It composes with the earlier cases: the payment system’s events drive these notifications, and statements draw on transaction data. This is the reactive, cost-optimized, compliance-focused corner of the banking platform, and it showcases event-driven, serverless, and tiered-storage patterns working together.
5.7 Troubleshooting the Design
Notification/statement design weaknesses are recognizable. Making notifications synchronous with payments would couple them and let notification problems affect payments - keep them event-driven and asynchronous. No queue buffering would let bursts overwhelm channels - buffer with queues and scale consumers to depth. No idempotency would send duplicate notifications on redelivery - make consumers idempotent. No dead-letter queue would let poison messages block delivery - add a DLQ. Storing statements without lifecycle tiering would be expensive - tier aging documents to cheaper storage. Storing them without object lock would fail immutability compliance - use object lock. Running always-on servers for intermittent work wastes money - use serverless. The design’s essence is event-driven decoupled reactivity, queue-buffered reliable delivery with idempotency and DLQs, serverless for the spiky/periodic work, and tiered immutable S3 storage for compliant documents.
Design a notifications and statements system. Why is it a good fit for event-driven and serverless patterns?
I’d design it as an event-driven, largely serverless system because its defining characteristics - reacting to events, handling bursts, tolerating slight delay, and storing documents long-term for compliance - map exactly to those patterns. The requirements: functionally, react to events like a payment being made by notifying customers through channels (push, email, SMS), and periodically generate statements and retain them for years immutably for compliance; non-functionally, handle high volume and bursts, be reliable so notifications aren’t lost and statements are retained and tamper-proof, tolerate the notification happening slightly after the event, and be cost-effective for years of storage. The architecture is event-driven: business events are published (via SNS or EventBridge) and consumed by a notification service that determines recipients and channels and sends messages, buffered through SQS queues so bursts are absorbed and delivery is reliable and retryable, with a dead-letter queue for repeatedly-failing messages and idempotent consumers so a redelivered event doesn’t send a duplicate. Statement generation runs as scheduled asynchronous work producing documents stored in S3. It’s a good fit for event-driven patterns because notifications are triggered by events, which decouples them from the systems that produce those events - the payment system just publishes “PaymentMade” and the notification service reacts, so notification work never blocks or affects payments, and bursts are absorbed by queues that buffer load while consumers scale to the queue depth, with the queue’s durability and retries making delivery reliable. This is textbook asynchronous, event-driven, queue-based processing for reactive, bursty work. It’s a good fit for serverless because the work is event-driven and often spiky or intermittent - a notification function per event, a statement function on a schedule - so Lambda’s automatic scaling and zero idle cost are ideal: it scales to the burst and costs nothing between events with no servers to manage, which beats running always-on servers for intermittent notification and periodic statement work. For compliant storage, statements go in S3 with lifecycle policies moving aging documents to cheaper classes automatically (most are old and rarely read but retained for years), object lock for immutable tamper-proof retention, encryption, and versioning - keeping years of documents affordable, immutable, and secure. The trade-offs I’d name are that notifications are eventually consistent with the triggering event, which is fine because a confirmation moments after a payment is acceptable, and that the system uses at-least-once delivery with idempotent consumers rather than guaranteeing exactly-once at the messaging layer - prioritizing reliability and cost-effectiveness over strict timing. So it fits event-driven and serverless patterns because it’s reactive, bursty, intermittent, and downstream - decoupled from the payment path it reacts to, buffered and reliable through queues, scaled and idle-cost-free through serverless, and cost-effectively compliant through tiered immutable S3 storage.
Chapter Revision Notes
- Event-driven: notifications react to published events (e.g. PaymentMade), decoupled so they never affect the payment path.
- Queues buffer bursts and make delivery reliable/retryable; idempotent consumers prevent duplicate notifications; DLQs capture poison messages.
- Serverless (Lambda) fits the spiky, intermittent, event-driven and scheduled work - auto-scaling, zero idle cost, no servers to manage.
- Statements stored in S3 with lifecycle tiering (cheap long-term), object lock (immutable/compliant), encryption, and versioning.
- Trade-offs: eventual consistency with the event (acceptable) and at-least-once delivery with idempotency - prioritizing reliability and cost over strict timing.