AWS ElastiCache
Memcached and Redis
- Memcached — A widely adopted in-memory key store, and historically the gold standard of web caching. ElastiCache is protocol-compliant with Memcached, so popular tools that you use today with existing Memcached environments will work seamlessly with the service. Memcached is also multithreaded, meaning it makes good use of larger Amazon EC2 instance sizes with multiple cores.
- Redis — an increasingly popular open-source key-value store that supports more advanced data structures such as sorted sets, hashes, and lists. Unlike Memcached, Redis has disk persistence built in, meaning that you can use it for long-lived data. Redis also supports replication, which can be used to achieve Multi-AZ redundancy, similar to Amazon RDS.
Memcached vs Redis
在决定使用 Memcached 还是 Redis 时,以下是一些需要考虑的问题:
- 如果您的主要目标是对象缓存,例如为了减轻数据库的负担,那么请使用 Memcached。
- 如果您想要一个尽可能简单的缓存模型,那么请使用 Memcached。
- 如果您计划运行大型缓存节点,并且需要多线程性能以及利用多个核心,那么请使用 Memcached。
- 如果您想要在成长过程中水平扩展您的缓存,那么请使用 Memcached。
- 如果您的应用程序需要原子地增加或减少计数器,那么您可以使用 Redis 或 Memcached。
- 如果您在寻找更高级的数据类型,例如列表、哈希、位数组、HyperLogLogs 和集合,那么请使用 Redis。
- 如果在内存中对数据集进行排序和排名对您有帮助,例如使用排行榜,那么请使用 Redis。
- 如果您的应用程序能够使用发布和订阅(pub/sub)功能,那么请使用 Redis。
- 如果您的关键存储持久化很重要,那么请使用 Redis。
- 如果您想要在多个 AWS 可用区(Multi-AZ)中运行并具有故障转移能力,那么请使用 Redis。
- 如果您的应用程序需要地理空间支持,那么请使用 Redis。
- 如果您的业务需要加密并符合 PCI DSS、HIPAA 和 FedRAMP 等标准,那么请使用 Redis。
Caching strategies
- Lazy loading
- Write-through
来源
- 比较 Redis 与 Memcached: https://aws.amazon.com/cn/elasticache/redis-vs-memcached/
- Memcached vs. Redis: https://docs.aws.amazon.com/zh_cn/whitepapers/latest/scale-performance-elasticache/memcached-vs.-redis.html
- Caching strategies: https://docs.aws.amazon.com/AmazonElastiCache/latest/mem-ug/Strategies.html