Database
D3 · Performance
D4 · Cost
~1 phút đọcCaching Strategies — ElastiCache, DAX, CloudFront Caching
Chiến lược caching: ElastiCache Redis vs Memcached cho application cache, DAX cho DynamoDB, CloudFront cho edge caching. Hiểu cache patterns và invalidation.
elasticache
redis
memcached
dax
cloudfront
caching
Sơ đồ tổng quan
Đang tải sơ đồ…
Tổng quan
Caching giảm latency và load cho database/origin. AWS cung cấp nhiều lớp cache: edge (CloudFront), application (ElastiCache), database-specific (DAX). Chọn đúng layer và pattern là key.
ElastiCache Redis vs Memcached
- Redis: data structures, persistence, replication, Multi-AZ, pub/sub, Lua scripting, cluster mode.
- Memcached: simple key-value, multi-threaded, no persistence, no replication.
- Redis Cluster Mode: sharding data across nodes, scale write + read.
- Redis Global Datastore: cross-region replication cho DR.
- 99% trường hợp: chọn Redis. Memcached chỉ khi cần simple ephemeral cache.
Cache Patterns
- Lazy Loading (Cache-Aside): read miss → query DB → write cache. Stale data possible.
- Write-Through: write DB + write cache đồng thời. Always fresh, write penalty.
- Write-Behind: write cache → async write DB. Fast write, risk data loss.
- TTL: set expiration, balance freshness vs hit rate.
- Cache Invalidation: application-level delete/update cache khi data thay đổi.
DAX & CloudFront Caching
- DAX: in-memory cache cho DynamoDB, microsecond latency, API-compatible (drop-in).
- DAX cluster: primary + read replicas, Multi-AZ.
- DAX vs ElastiCache: DAX chỉ cho DynamoDB, ElastiCache cho mọi DB.
- CloudFront: edge cache cho HTTP content, TTL-based, cache key (headers, cookies, query strings).
- CloudFront invalidation: tạo invalidation request hoặc dùng versioned URLs.
Info
Đề thi: 'giảm DynamoDB read latency xuống microsecond' → DAX. 'Cache cho RDS' → ElastiCache Redis. 'Cache static content globally' → CloudFront.
Nội dung liên quan
Quiz liên quan
Flashcards liên quan