Amazon ElastiCache is a fully managed in-memory data store and cache service that supports two popular open-source caching engines, Redis and Memcached. It is designed to improve the performance of web applications by enabling you to retrieve information from fast, managed, in-memory caches instead of relying entirely on slower disk-based databases. It’s a key/value store.
Key Features:
Significantly improves latency and throughput for read-heavy and compute-intensive application workloads. Best suited for Online Analytics Processing (OLAP) transactions. Redis: Offers advanced data structures, replication, persistence, and clustering. Memcached: A simpler, multi-threaded caching solution ideal for large, horizontal scaling. Scalability and Flexibility: Push-button scalability for memory, writes, and reads. Nodes can be easily added or removed to meet demand. High Availability and Reliability: Nodes are automatically replaced in case of failure. Redis supports master/slave replication, automatic failover, and cross-AZ high availability. Access controlled via VPC security groups and subnet groups. Nodes are not accessible from the Internet or across different VPCs. Supports encryption in transit and at rest (for Redis). Billed based on node size and hours of use. Options for on-demand or reserved instances (but not Spot instances). Integration and Management: Fully integrated with other AWS services. Simplified management through the AWS Management Console, CLI, SDKs, and APIs. Maintenance windows for software patching. Use Cases:
Session Store: Store session data for web applications to provide a fast and reliable user experience. Database Query Caching: Cache the results of frequently executed database queries to reduce database load and improve response times. Computational Caching: Cache the results of computationally intensive operations to save resources and reduce processing times. Leaderboards/Counting: Use Redis for storing real-time leaderboards and counters due to its advanced data structures. Streaming Data: Utilize Redis for real-time data processing and analytics, leveraging its support for streams and other data types. ElastiCache Architecture:
The smallest building block, each node is a fixed-size chunk of secure, network-attached RAM. Runs an instance of either Memcached or Redis. Each node has its own DNS name and port. A collection of one or more nodes using the same caching engine. Nodes within a cluster can span multiple subnets of the same subnet group. A collection of subnets designated for your ElastiCache clusters within a VPC. Required for deploying ElastiCache in a VPC. Unique addresses used by applications to connect to ElastiCache nodes or clusters. Maintenance and Updates:
Maintenance windows can be defined to allow software patching to occur. ElastiCache automatically applies updates during these windows to ensure minimal disruption. Engine Differences:
Simpler model with support for large nodes and multiple cores/threads. Can easily scale in and out. Ideal for caching objects and DB results. More complex model with support for encryption, replication, high availability, and backup/restore. Supports advanced data structures, such as sorted sets and hashes. Can be configured for cross-AZ replication and automatic failover.
Exam tip: the key use cases for ElastiCache are offloading reads from a database and storing the results of computations and session state. Also, remember that ElastiCache is an in-memory database and it’s a managed service (so you can’t run it on EC2).