11 Caching data in memory: Amazon ElastiCache and MemoryDB

 

This chapter covers

  • The benefits of a having a caching layer between your application and data store
  • Defining key terminology, such as cache cluster, node, shard, replication group, and node group
  • Using /operating an in-memory key-value store
  • Performance tweaking and monitoring ElastiCache clusters

Imagine a relational database being used for a popular mobile game where players’ scores and ranks are updated and read frequently. The read and write pressure to the database will be extremely high, especially when ranking scores across millions of players. Mitigating that pressure by scaling the database may help with load but not necessarily the latency or cost. Also, caching relational databases tends to be more expensive than caching data stores.

A proven solution used by many gaming companies is leveraging an in-memory data store such as Redis for both caching and ranking player and game metadata. Instead of reading and sorting the leaderboard directly from the relational database, they store an in-memory game leaderboard in Redis, commonly using a sorted set, which will sort the data automatically when it’s inserted, based on the score parameter. The score value may consist of the actual player ranking or player score in the game.

11.1 Creating a cache cluster

 
 
 
 

11.1.1 Minimal CloudFormation template

 
 
 
 

11.1.2 Test the Redis cluster

 
 
 

11.2 Cache deployment options

 
 
 
 

11.2.1 Memcached: Cluster

 
 

11.2.2 Redis: Single-node cluster

 
 
 
 

11.2.3 Redis: Cluster with cluster mode disabled

 
 
 
 

11.2.4 Redis: Cluster with cluster mode enabled

 
 

11.2.5 MemoryDB: Redis with persistence

 
 
 

11.3 Controlling cache access

 
 
 

11.3.1 Controlling access to the configuration

 
 
 

11.3.2 Controlling network access

 
 
 
 

11.3.3 Controlling cluster and data access

 
 
 
 

11.4 Installing the sample application Discourse with CloudFormation

 
sitemap

Unable to load book!

The book could not be loaded.

(try again in a couple of minutes)

manning.com homepage
test yourself with a liveTest