Relational database
Amazon RDS / Amazon Aurora
Source of truth for structured data with transactions, joins and constraints (Postgres/MySQL).
In a monolith
One shared database
Every module reads and writes the same schema — easy joins and transactions, but every team depends on every table.
In a distributed system
Database per service
Each service owns its schema; others go through its API or events. Cross-service joins become API calls or replicated read models.
On AWS
Amazon RDS / Amazon Aurora
Managed Postgres/MySQL with automated backups, a Multi-AZ standby for failover, and read replicas.
- RDS PostgreSQL / MySQL$$Managed engine, Multi-AZ standby, vertical scaling
- Aurora (Postgres/MySQL compatible)$$$Shared storage, fast failover, low-lag replicas
- Aurora Serverless v2$$Capacity follows load — good for spiky traffic
- Self-managed on EC2$$Full control, full responsibility
- Reach for it when
- Data with relationships and invariants (balances, inventory) that needs transactions.
- What it costs you
- Writes scale vertically; horizontal write scaling means sharding (hard)
- Connection limits are in the hundreds, not tens of thousands
- Schema migrations need care at scale
- When it dies
- Without a standby, the primary dying means downtime until it’s restored — and possible data loss since the last backup. With Multi-AZ, a standby takes over in a minute or two.
Interview follow-ups
How do you scale a relational database?
In order: indexes and query fixes → caching → read replicas → vertical scaling → partitioning/sharding (or move hot paths to NoSQL).
SQL vs NoSQL?
SQL: relations, transactions, flexible queries. NoSQL: predictable latency at huge scale for known access patterns and easy horizontal scaling, with weaker joins/transactions.
Multi-AZ standby vs read replica?
A Multi-AZ standby is synchronous and exists for failover. A read replica is asynchronous and serves reads, but lags.
Connection rules
It talks to
- Read replica
- Event stream
- SQL databaseOnly when: Cross-region replicas or global databases (e.g. Aurora Global Database) where one region stays the writer.
- QueueOnly when: A CDC connector or outbox relay tails the log and publishes — the transactional outbox pattern.
- Pub/sub topicOnly when: A CDC connector or outbox relay tails the log and publishes — the transactional outbox pattern.
Gets traffic from
- App server
- Service
- Worker
- Realtime server
- DB proxy
- ClientsOnly when: BaaS-style setups (Supabase, Firebase) where row-level security or security rules enforce access inside the database itself.
- CacheOnly when: Read-through / write-through caches that load from the DB themselves (e.g. DAX in front of DynamoDB).
Never
- CDN → SQL databaseCDN origins are HTTP servers or buckets, never databases or caches.
- Load balancer → SQL databaseA load balancer forwards HTTP to compute. Data access needs code: auth, queries, validation.
- API gateway → SQL databaseA gateway routes to compute; data access needs your code.
- Queue → SQL databaseQueues don’t run code. A consumer reads the message and does the write or call.
- Pub/sub topic → SQL databaseTopics don’t run code. A subscriber receives the event and does the write.
- Event stream → SQL databaseStreams don’t run code. A consumer reads the records and does the write or call.