NoSQL / key-value store
Amazon DynamoDB
A horizontally partitioned store with predictable latency at any scale — tables are designed around access patterns.
In a monolith
Usually not needed yet
Most monoliths start on one relational DB. NoSQL appears for one hot, simple access pattern: sessions, carts, short links.
In a distributed system
Per-service store for hot paths
Services with huge, simple key-based access (by ID, time-ordered items per user) use partitioned key-value/document stores.
On AWS
Amazon DynamoDB
Serverless key-value/document DB: single-digit-ms latency, on-demand or provisioned capacity, Streams for change capture, global tables for multi-region.
- DynamoDB on-demand$$Pay per request; absorbs spikes
- DynamoDB provisioned + auto scaling$Cheaper at steady load
- DynamoDB global tables$$$Multi-region active-active replication
- DocumentDB / Keyspaces$$Mongo/Cassandra-compatible options
- Reach for it when
- Massive scale with known access patterns, or a serverless datastore with predictable latency.
- What it costs you
- Access patterns must be designed up front; ad-hoc queries are hard
- Hot partitions: one popular key can throttle
- Limited joins and transactions compared to SQL
- When it dies
- Managed NoSQL replicates across AZs automatically; a regional outage is the main risk (global tables mitigate it).
Interview follow-ups
What is a hot partition and how do you avoid it?
Too much traffic on one partition key (a celebrity, a viral product). Spread it with better keys, write sharding (key#suffix), or cache the hot items.
How do you choose a partition key?
High cardinality, evenly accessed, and part of your main query (e.g. userId for “items of a user”).
Connection rules
It talks to
- Event stream
- NoSQL storeOnly when: Global tables replicating across regions (multi-active).
- 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
- Workflow
- ClientsOnly when: Fine-grained per-user access through an identity provider (e.g. Cognito identity pools with DynamoDB leading-key conditions) — rare, and only for simple per-user data.
- API gatewayOnly when: API Gateway → DynamoDB integration for trivial reads/writes with request mapping and no business logic.
- CacheOnly when: Read-through / write-through caches that load from the DB themselves (e.g. DAX in front of DynamoDB).
Never
- CDN → NoSQL storeCDN origins are HTTP servers or buckets, never databases or caches.
- Load balancer → NoSQL storeA load balancer forwards HTTP to compute. Data access needs code: auth, queries, validation.
- Queue → NoSQL storeQueues don’t run code. A consumer reads the message and does the write or call.
- Pub/sub topic → NoSQL storeTopics don’t run code. A subscriber receives the event and does the write.
- Event stream → NoSQL storeStreams don’t run code. A consumer reads the records and does the write or call.