Amazon ElastiCache Popular2011年〜
An in-memory caching service delivering microsecond response times
What It Does
Amazon ElastiCache is a fully managed caching service that keeps data in memory for ultra-fast microsecond-level data access. It supports two engines: Redis and Memcached. By caching database query results and session information, it can dramatically improve overall application response times.
Use Cases
It is used for caching database query results, web application session management, real-time rankings and leaderboards, API response caching, message brokering, and geospatial data processing - anywhere high-speed data access is needed.
Everyday Analogy
Think of it like a notepad on your desk. Going to the file room (database) to retrieve documents takes time, but if you jot down frequently used information on your desk notepad (ElastiCache), you can reference it instantly. Since notepad space is limited, less frequently used information goes back to the file room.
What Is ElastiCache?
Amazon ElastiCache is a fully managed in-memory data store service from AWS. In-memory means data is kept in RAM rather than on disk, enabling dramatically faster reads and writes since disk access is eliminated. Placed as a cache layer in front of a database, it reduces database load while significantly improving application response times.
Redis vs. Memcached
ElastiCache supports two engines: Redis and Memcached. Redis offers rich features including data persistence, replication, sorted sets, and Pub/Sub messaging, making it useful beyond just caching. Memcached specializes in simple key-value caching with high throughput through multi-threading. When in doubt, Redis is the common choice due to its richer feature set.
Caching Strategies
There are two fundamental caching strategies. Lazy Loading checks the cache when data is requested and, if not found, fetches from the database and stores it in the cache. Write Through updates the cache simultaneously with database writes. Setting a TTL (time to live) to automatically remove stale cache entries is important for maintaining data freshness. For design patterns and operational practices for caching strategies, books (Amazon) provide detailed coverage.
Getting Started
To get started, click 'Create cluster' in the ElastiCache console. Select an engine (Redis or Memcached), specify the node type (performance) and number of nodes. Configure the VPC and subnets, and your cluster will be up in minutes. Connect from your application using Redis or Memcached client libraries.
Things to Watch Out For
- Since data is in memory, it can be lost during node failures. Use Redis replication to ensure availability
- Without proper TTL settings, stale data may continue to be served
- ElastiCache nodes are charged continuously while running, so choose smaller node types for development environments