Cloud Computing Tutorial · Storage and Databases · Lesson 18 of 24
NoSQL Databases
Key-value and document databases (DynamoDB, Cosmos DB, Firestore, Bigtable): partition keys, access patterns and hot partitions.
When NoSQL fits
Managed NoSQL databases scale to huge request rates with predictable latency, as long as you design for your access patterns up front.
| AWS | Azure | Google Cloud | |
|---|---|---|---|
| Key-value / document, serverless | DynamoDB | Cosmos DB | Firestore |
| Wide-column, very high throughput | Keyspaces (Cassandra) | Cosmos DB for Apache Cassandra, Managed Instance for Apache Cassandra | Bigtable |
| In-memory cache | ElastiCache, MemoryDB | Azure Managed Redis | Memorystore |
Partition keys
Data is spread across partitions by a partition key. Every partition has throughput limits (in DynamoDB, about 3,000 reads and 1,000 writes per second), so a key that receives a large share of traffic becomes a hot partition and gets throttled even if the table as a whole has spare capacity.
import hashlib
from collections import Counter
PARTITIONS = 4
def partition(key):
return int(hashlib.md5(key.encode()).hexdigest(), 16) % PARTITIONS
writes_by_date = Counter(partition("2026-11-27") for _ in range(4000)) # key = today's date
writes_by_order = Counter(partition(f"order-{i}") for i in range(4000)) # key = order id
print("key=date: writes per partition", [writes_by_date.get(p, 0) for p in range(PARTITIONS)])
print("key=order_id: writes per partition", [writes_by_order.get(p, 0) for p in range(PARTITIONS)])
Output
key=date: writes per partition [0, 0, 4000, 0] key=order_id: writes per partition [986, 1019, 972, 1023]
Good keys have many distinct values with evenly spread traffic: customer_id, order_id, or a key with a
suffix spread across N shards for very hot items.
Test yourself
A DynamoDB table keyed by event date is throttled although total capacity is unused. Why?
All of today's writes go to one partition (a hot key)DynamoDB can't store datesThe table is too smallRead replicas are lagging
Show answer
Answer: All of today's writes go to one partition (a hot key)
Throughput is limited per partition; choose a key that spreads traffic evenly.