NoSQL, Caches and Messaging
The "everything else" of a typical backend: a key-value or document database, a Redis-compatible cache, and queues and event buses between services. The products map clearly; the pricing models and the semantics (ordering, delivery guarantees) need care.
On AWS this is… Amazon DynamoDB, Amazon ElastiCache and SQS, SNS and EventBridge.
NoSQL databases
| AWS | Azure | Google Cloud | |
|---|---|---|---|
| Key-value / document, serverless | DynamoDB | Azure Cosmos DB (API for NoSQL; also MongoDB, Cassandra, Gremlin, Table APIs) | Firestore (document, serverless) |
| Wide-column, huge scale | Keyspaces (Cassandra) | Cosmos DB for Apache Cassandra, Azure Managed Instance for Apache Cassandra | Bigtable |
| MongoDB-compatible | DocumentDB | Cosmos DB for MongoDB (RU and vCore) | Firestore with MongoDB compatibility |
| Capacity unit | RCUs/WCUs or on-demand | Request Units (RU/s), provisioned, autoscale or serverless | per document read/write/delete (Firestore); nodes (Bigtable) |
| Partitioning | partition key | partition key (choose at container creation) | automatic (Firestore); row key design (Bigtable) |
| Global multi-region writes | Global Tables | multi-region writes, five consistency levels | Firestore multi-region locations; Bigtable replication |
Cosmos DB's five consistency levels (strong, bounded staleness, session, consistent prefix, eventual) are a notable feature; session is the default and what most apps want ("read your own writes").
Whatever the product, the partition (or row) key decides whether load spreads evenly. A model of a hot partition:
import hashlib
from collections import Counter
PARTITIONS = 8
def partition(key):
return int(hashlib.sha256(key.encode()).hexdigest(), 16) % PARTITIONS
# 10,000 order writes in one hour: 60% belong to one big customer
orders = [("cust-big" if i % 10 < 6 else f"cust-{i % 997}", i) for i in range(10_000)]
def spread(keyfunc):
counts = Counter(partition(keyfunc(c, i)) for c, i in orders)
hottest = max(counts.values())
return hottest, hottest / (len(orders) / PARTITIONS)
for name, keyfunc in [
("customerId", lambda c, i: c),
("orderId", lambda c, i: f"order-{i}"),
("customerId + suffix 0-15", lambda c, i: f"{c}#{i % 16}"), # write sharding
]:
hottest, ratio = spread(keyfunc)
print(f"{name:<24} hottest partition {hottest:>5} writes ({ratio:.1f}x the even share)")customerId hottest partition 6453 writes (5.2x the even share)
orderId hottest partition 1342 writes (1.1x the even share)
customerId + suffix 0-15 hottest partition 2338 writes (1.9x the even share)
Keying by customer puts most of the big customer's traffic on one partition, which hits that partition's throughput limit (RU/s per physical partition in Cosmos DB, per-partition limits in DynamoDB) long before the total is reached. Adding a suffix, or a hierarchical partition key in Cosmos DB, spreads it.
Caches
| AWS | Azure | Google Cloud | |
|---|---|---|---|
| Managed Redis / Valkey | ElastiCache (Valkey, Redis OSS, Memcached), MemoryDB | Azure Managed Redis (Microsoft is retiring Azure Cache for Redis in its favour) | Memorystore for Valkey, Redis Cluster, Redis; Memorystore for Memcached |
| Private access | in your VPC subnets | private endpoint | private services access or Private Service Connect |
If you find an older Azure design using "Azure Cache for Redis", plan the move to Azure Managed Redis; check Microsoft's retirement timeline for the dates.
Messaging
| Job | AWS | Azure | Google Cloud |
|---|---|---|---|
| Work queue | SQS | Service Bus queues (rich: sessions, dead-lettering, transactions); Storage Queues (simple, cheap) | Pub/Sub subscription (pull); Cloud Tasks for dispatching HTTP tasks |
| FIFO / ordering | SQS FIFO | Service Bus sessions | Pub/Sub ordering keys |
| Fan-out pub/sub | SNS | Service Bus topics + subscriptions | Pub/Sub topics + subscriptions |
| Event routing from cloud services | EventBridge | Event Grid | Eventarc |
| Streaming (Kafka-like) | Kinesis, MSK | Event Hubs (Kafka-compatible endpoint) | Pub/Sub, Managed Service for Apache Kafka |
| Workflows | Step Functions | Logic Apps, Durable Functions | Workflows |
Google Cloud's Pub/Sub covers both SQS-style and SNS-style use: a topic fans out to any number of subscriptions, and each subscription is a durable queue with its own acknowledgement deadline and dead-letter topic. On Azure, use Service Bus for business messaging and Event Grid for "something happened" notifications from Azure resources.
Sample sessions:
# Azure Service Bus: a namespace, a queue with dead-lettering, a topic with a subscription
az servicebus namespace create -g rg-shop-prod-app -n sb-shop-prod -l westeurope --sku Standard
az servicebus queue create -g rg-shop-prod-app --namespace-name sb-shop-prod -n orders \
--max-delivery-count 5 --enable-dead-lettering-on-message-expiration true
az servicebus topic create -g rg-shop-prod-app --namespace-name sb-shop-prod -n order-events
az servicebus topic subscription create -g rg-shop-prod-app --namespace-name sb-shop-prod \
--topic-name order-events -n billing
# Google Cloud Pub/Sub: a topic, a pull subscription with a dead-letter topic
gcloud pubsub topics create order-events
gcloud pubsub topics create order-events-dlq
gcloud pubsub subscriptions create billing --topic=order-events \
--ack-deadline=60 --dead-letter-topic=order-events-dlq --max-delivery-attempts=5
gcloud pubsub topics publish order-events --message='{"order":1001,"total":42.50}'
gcloud pubsub subscriptions pull billing --auto-ack --limit=1All three clouds' standard queues deliver at least once: consumers must be idempotent. Exactly-once features exist (SQS FIFO deduplication, Service Bus duplicate detection, Pub/Sub exactly-once delivery on pull subscriptions), each with its own limits.
Test yourself
What is the Azure service closest to SQS with dead-lettering, sessions and transactions?
- Event Grid
- Service Bus queues
- Event Hubs
- Storage Queues
How does Google Cloud Pub/Sub provide both SNS-style fan-out and SQS-style queues?
- Two separate products
- A topic fans out to many subscriptions; each subscription is a durable queue
- Only through Eventarc
- It doesn't
Why is customerId a risky partition key when one customer produces most writes?
- It is too long
- That customer's writes concentrate on one partition and hit its throughput limit
- Keys must be numbers
- It prevents queries