資料庫題其實是 data contract:哪些 query 要快、哪些 transaction 要 atomic、資料會長多大、client 允許看到什麼 consistency?
Relational availability 不是 read scaling
RDS Multi-AZ 以 synchronous standby 做 failover,通常不是 read target。Read replica 用 asynchronous replication 擴讀,也能 promote,但不是同一種 automatic-HA contract。Aurora 將 distributed storage 與 compute 分離,提供 writer/reader endpoints,並支援 replica、Serverless、Global Database pattern。
RDS Proxy 做 connection pooling,避免 Lambda concurrency 等 burst 壓垮 relational database;它不 cache query result。
DynamoDB 從 access pattern 開始
DynamoDB 以 partition/sort key 提供 key-value/document access。Traffic 難預測用 on-demand;可預測且願意管 capacity 用 provisioned。GSI 增加新 partition-key access pattern,有自己的 capacity 影響;LSI 與 base table 共用 partition key,且建 table 時就要定義。
Global Tables 是 Multi-Region active-active。DAX cache DynamoDB read。DynamoDB Streams 記錄 item change 供 event processing。
Cache 與 purpose-built store
ElastiCache Redis 有更豐富 data structure、replication、persistence option 與 sorted set;Memcached 是較簡單 distributed cache。Cache 降 latency/load,但會帶來 invalidation 與 staleness 決策。
DocumentDB 對 MongoDB-compatible document workload;Neptune 對 graph;Keyspaces 對 Cassandra-compatible wide column;Timestream 對 time series。Compatible 不代表與 upstream 完全一樣。
考試視角: 先選 data model,再把 availability、read scaling、caching、global replication 當成四個獍立需求。
複習卡
- Multi-AZ 是 HA;read replica 是 read scaling。
- RDS Proxy pool connection;ElastiCache cache data。
- DynamoDB 從 partition key 與 access pattern 設計。
- DAX 專門 cache DynamoDB。
- Query model 真的特殊時才選 purpose-built database。