Cloud Platforms
Other AWS Databases
Purpose-built databases: DocumentDB, ElastiCache and MemoryDB, Neptune, Timestream, Keyspaces and OpenSearch, with examples and a guide to choosing.
Contents
1. Purpose-Built Databases on AWS
AWS offers a database for each data model. Data engineers often extract from these, feed them as serving layers, or choose between them in design discussions.
| Service | Model | Typical use |
|---|---|---|
| RDS / Aurora | Relational | Transactions, ERP/CRM back-ends |
| DynamoDB | Key-value / document | High-scale apps, pipeline state, serving |
| DocumentDB | Document (MongoDB-compatible API) | JSON document apps migrating from MongoDB |
| ElastiCache (Valkey, Redis OSS, Memcached) | In-memory key-value | Caching, sessions, leaderboards, rate limiting |
| MemoryDB | Durable in-memory (Valkey/Redis compatible) | Primary database needing microsecond reads with durability |
| Neptune | Graph (Gremlin, openCypher, SPARQL) | Fraud rings, recommendations, knowledge graphs |
| Keyspaces | Wide-column (Cassandra-compatible) | Cassandra workloads without managing clusters |
| Timestream | Time series | IoT, metrics and telemetry with time-based queries |
| OpenSearch Service | Search and log analytics (also vectors) | Full-text search, log analytics, vector search for RAG |
| Redshift | Columnar warehouse | Analytics and BI |
2. DocumentDB
from pymongo import MongoClient
client = MongoClient("mongodb://app:<password>@docdb-cluster.cluster-xyz.ap-south-1.docdb.amazonaws.com:27017/"
"?tls=true&tlsCAFile=global-bundle.pem&replicaSet=rs0&readPreference=secondaryPreferred"
"&retryWrites=false")
orders = client["shop"]["orders"]
orders.create_index([("customer_id", 1), ("order_ts", -1)])
recent = list(orders.find({"customer_id": "C1"}).sort("order_ts", -1).limit(10))
- Implements much of the MongoDB API, but not every feature or operator: test compatibility before migrating.
- Storage architecture similar to Aurora: shared storage across three AZs, up to 15 replicas.
- Change streams provide CDC; DMS can migrate from MongoDB or extract to S3.
3. ElastiCache & MemoryDB
import redis, json
r = redis.Redis(host="risk-cache.xxxxxx.aps1.cache.amazonaws.com", port=6379, ssl=True)
def get_risk_score(account_id: str) -> dict:
cached = r.get(f"risk:{account_id}")
if cached:
return json.loads(cached) # cache hit: microseconds
score = load_from_feature_store(account_id) # cache miss: slower source
r.setex(f"risk:{account_id}", 300, json.dumps(score)) # expire after 5 minutes
return score
- Cache-aside (above) is the most common pattern; set TTLs so stale values expire.
- ElastiCache is a cache (data can be lost on failure); MemoryDB keeps a durable transaction log so it can be the primary database.
- Valkey is the open-source fork of Redis supported by both services.
4. Neptune for Graph Problems
// openCypher: accounts sharing a device with a known fraudulent account (fraud ring detection)
MATCH (bad:Account {flagged: true})-[:USED]->(d:Device)<-[:USED]-(other:Account)
WHERE other <> bad
RETURN d.device_id, collect(DISTINCT other.account_id) AS linked_accounts
LIMIT 50;
Graph databases shine when the question is about relationships several hops deep (rings, networks, lineage). Load data in bulk from S3 with the Neptune bulk loader.
5. Timestream, Keyspaces & OpenSearch
| Service | Key ideas |
|---|---|
| Timestream | Measures with dimensions and timestamps; memory store for recent data and magnetic store for history; SQL with time-series functions (binning, interpolation). Timestream for InfluxDB offers managed InfluxDB |
| Keyspaces | Serverless Cassandra Query Language (CQL); partition keys and clustering columns like Cassandra; on-demand or provisioned capacity |
| OpenSearch Service | Indexes documents for full-text search and aggregations; OpenSearch Serverless removes cluster sizing; k-NN vector indexes support semantic search and RAG; ingest via Firehose or OpenSearch Ingestion |
6. Choosing a Database
| If you need… | Use |
|---|---|
| Relational integrity, joins, transactions | RDS / Aurora |
| Predictable single-digit ms at any scale by key | DynamoDB |
| Microsecond reads, caching | ElastiCache (MemoryDB if it must be durable) |
| Flexible JSON documents with MongoDB drivers | DocumentDB |
| Multi-hop relationship queries | Neptune |
| Time-stamped metrics and telemetry | Timestream |
| Full-text, log or vector search | OpenSearch Service |
| Large-scale analytics | Redshift, or Athena on S3 |
7. Common Interview Questions
| Question | Short answer |
|---|---|
| What is "purpose-built databases"? | Choosing the database whose data model and access patterns fit each workload, instead of one database for everything |
| ElastiCache vs MemoryDB? | ElastiCache is a cache (may lose data); MemoryDB is a durable in-memory primary database with a multi-AZ transaction log |
| When would you use a graph database for fraud? | To find rings and shared attributes (devices, addresses, cards) across many hops, which is slow and complex with relational joins |
| Is DocumentDB the same as MongoDB? | It is MongoDB-API-compatible but a different implementation; most drivers and many features work, but compatibility must be tested |