Performance at Scale with Amazon ElastiCache

Performance at Scale with Amazon ElastiCache

July 2019

Notices

Customers are responsible for making their own independent assessment of the information in this document. This document: (a) is for informational purposes only, (b) represents current AWS product offerings and practices, which are subject to change without notice, and (c) does not create any commitments or assurances from AWS and its affiliates, suppliers or licensors. AWS products or services are provided "as is" without warranties, representations, or conditions of any kind, whether express or implied. The responsibilities and liabilities of AWS to its customers are controlled by AWS agreements, and this document is not part of, nor does it modify, any agreement between AWS and its customers.

? 2019 Amazon Web Services, Inc. or its affiliates. All rights reserved.

Contents

Introduction ..........................................................................................................................1 ElastiCache Overview .........................................................................................................2 Alternatives to ElastiCache .................................................................................................2 Memcached vs. Redis .........................................................................................................3 ElastiCache for Memcached ...............................................................................................5

Architecture with ElastiCache for Memcached................................................................5 Selecting the Right Cache Node Size .............................................................................9 Security Groups and VPC..............................................................................................10 Caching Design Patterns...................................................................................................12 How to Apply Caching....................................................................................................12 Consistent Hashing (Sharding)......................................................................................13 Client Libraries ...............................................................................................................15 Be Lazy...........................................................................................................................16 Write On Through...........................................................................................................18 Expiration Date...............................................................................................................20 The Thundering Herd .....................................................................................................21 Cache (Almost) Everything ............................................................................................22 ElastiCache for Redis ........................................................................................................22 Architecture with ElastiCache for Redis ........................................................................23 Distributing Reads and Writes .......................................................................................25 Multi-AZ with Auto-Failover............................................................................................26 Sharding with Redis .......................................................................................................27 Advanced Datasets with Redis .........................................................................................31 Game Leaderboards ......................................................................................................31 Recommendation Engines.............................................................................................31 Chat and Messaging ......................................................................................................32

Queues ...........................................................................................................................33 Client Libraries and Consistent Hashing .......................................................................33 Monitoring and Tuning.......................................................................................................34 Monitoring Cache Efficiency ..........................................................................................34 Watching for Hot Spots ..................................................................................................36 Memcached Memory Optimization ................................................................................37 Redis Memory Optimization...........................................................................................38 Redis Backup and Restore ............................................................................................38 Cluster Scaling and Auto Discovery..................................................................................39 Auto Scaling Cluster Nodes ...........................................................................................39 Auto Discovery of Memcached Nodes ..........................................................................39 Cluster Reconfiguration Events from Amazon SNS......................................................41 Conclusion .........................................................................................................................43 Contributors .......................................................................................................................43 Further Reading.................................................................................................................43 Document Revisions..........................................................................................................43

Abstract

In-memory caching improves application performance by storing frequently accessed data items in memory, so that they can be retrieved without access to the primary data store. Properly leveraging caching can result in an application that not only performs better, but also costs less at scale. Amazon ElastiCache is a managed service that reduces the administrative burden of deploying an in-memory cache in the cloud.

Beyond caching, an in-memory data layer also enables advanced use cases, such as analytics and recommendation engines. This whitepaper lays out common ElastiCache design patterns, performance tuning tips, and important operational considerations to get the most out of an in-memory layer.

................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download