Trung BìnhAWS & Cloud iconAWS & Cloud

Amazon ElastiCache là gì? Phân biệt Redis và Memcached trên ElastiCache. Các pattern caching phổ biến?

Amazon ElastiCache là dịch vụ managed in-memory caching, hỗ trợ Redis và Memcached, giúp giảm latency database và tăng throughput ứng dụng.

ElastiCache for Redis hỗ trợ data structures phong phú (strings, hashes, lists, sets, sorted sets, streams), persistence (RDB/AOF snapshots), replication (primary + read replicas), cluster mode (sharding tự động), pub/sub, Lua scripting, transaction; phù hợp cho session store, leaderboard, pub/sub, distributed locking, job queue. ElastiCache for Memcached đơn giản hơn, chỉ key-value string, multi-threaded (tận dụng multi-core tốt hơn), không có persistence hay replication, dễ horizontal scale; phù hợp khi chỉ cần simple object caching và horizontal scaling thuần túy.

Caching patterns:
- Cache-aside (lazy loading) — app check cache trước, miss thì query DB rồi populate cache
- Write-through — ghi vào cache và DB đồng thời, data luôn fresh nhưng write latency cao
- Write-behind (write-back) — ghi vào cache trước, async sync xuống DB, giảm write latency nhưng risk data loss
- Read-through — cache layer tự handle DB read khi miss

TTL đặt phù hợp tránh stale data; Cache Stampede problem giải quyết bằng mutex/probabilistic early expiration. ElastiCache Serverless (2023) tự scale capacity tự động.

Xem toàn bộ AWS & Cloud cùng filter theo level & chủ đề con.

Mở danh sách AWS & Cloud