liveBook · Manning

Memcached

As explained in Amazon Web Services in Action, Third Edition: An in-depth guide to AWS

Memcached is a distributed in-memory key-value caching system designed for storing transient application data.

Memcached is a simple in-memory key-value store. It is useful as a cache when an application can retrieve the original data elsewhere. A web application, for example, can cache the result of a SQL query while the relational database remains the source of truth. section 11.2.1 section 11.7

For a database-backed cache:

  • Choose a key, such as the SQL query, and ask the cache for its result. section 11.0
  • If the result is missing, read it from the database and store it in the cache. The query cache needs only simple operations such as GET and SET. section 11.0 section 11.2.1
  • Plan how cached values stay current: items can expire, or the application can use a write-through strategy. section 11.7

Amazon ElastiCache runs Memcached as a managed cluster of 1–40 nodes. The client typically uses consistent hashing to decide which node holds each key; every node stores a distinct portion of the keys. Adding nodes can increase available memory and throughput. Cluster nodes can be placed across multiple subnets for availability. section 11.2.1 section 11.7

Figure 11.4 Memcached deployment option: Cluster

The cluster diagram shows how clients reach the nodes that hold cached data. section 11.2.1

Choose Memcached when the application needs a simple cache and can tolerate losing cached data: a failed node is replaced, but its data is lost. Memcached has no backup or replication in this deployment and does not provide user authentication. Use IAM to control cluster administration and security groups to restrict network traffic to its nodes. If backup, replication, or more complex data structures are required, compare the Redis deployment options instead. section 11.2 section 11.2.1 section 11.3 section 11.3.3

How Amazon Web Services in Action, Third Edition: An in-depth guide to AWS covers it

How deep it goes
Explains cluster layout, client-side sharding, and failure consequences, but focuses hands-on cluster creation on Redis.
Examples
Uses a relational-database SQL query cache that needs only GET and SET and can survive loss of cached results.
What it assumes
Defines VPC as a private AWS network and subnet as a division within it before describing cluster placement.
What you can do after
Evaluate/understand when an ElastiCache for Memcached cluster fits a workload and what node loss means for cached data.
How it connects
Connects Memcached to SQL query caching, consistent hashing, Amazon ElastiCache, and Redis deployment choices.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Amazon Web Services in Action, Third Edition: An in-depth guide to AWS. The section links point to the parts of the book it draws on.