Lesson 6 of 7 · 10 min
Databases and decoupling
Choose a data store by access pattern, and use queues and events to stop components failing together.
Picking a data store
| Need | Service |
|---|---|
| Relational, familiar engines | RDS (MySQL, PostgreSQL, SQL Server, Oracle) |
| Relational with higher throughput and fast replicas | Aurora |
| Key-value at any scale, known access patterns | DynamoDB |
| In-memory cache | ElastiCache (Redis or Memcached) |
| Analytical queries over large history | Redshift, or Athena over S3 |
| Time-series, graph, ledger | Timestream, Neptune, QLDB |
DynamoDB's one demand
DynamoDB scales without limit provided the partition key spreads traffic. Capacity is allocated per partition, so a low-cardinality or skewed key throttles even when the table has plenty of unused capacity overall — the single most common DynamoDB surprise.
It also means you must know your access patterns before designing the table. Ad-hoc querying and joins are exactly what it is bad at; if the question mentions unpredictable reporting queries, the answer is relational.
The integration services
| Service | Model | Use for |
|---|---|---|
| SQS | Queue — one consumer per message | Load levelling, buffering, retries |
| SNS | Pub/sub — every subscriber gets a copy | Fan-out to several independent consumers |
| EventBridge | Event bus with rule-based routing | Reacting to AWS and SaaS events |
| Kinesis | Ordered, replayable stream | High-volume telemetry, multiple readers, replay |
| Step Functions | State machine | Multi-step workflows with retries and approvals |
What decoupling actually buys
Putting a queue between a fast producer and a slow consumer means a traffic spike lengthens the queue instead of taking down the backend. The front end stays available even when the downstream is degraded.
The costs are real and must be deliberate: end-to-end latency rises, and standard SQS delivers at least once, so consumers must be idempotent. The usual pattern is recording an idempotency key with a conditional write before acting.
Worth remembering
- Multi-AZ is availability; read replicas are read scaling. They are not interchangeable.
- DynamoDB needs the access pattern known when you design the key.
- A queue converts a hard dependency into a buffered one, at the cost of latency and duplicates.
Test it now
Database selection and queue semantics recur throughout the bank.