Skip to content

Elasticache

General Info

Description
  • Service that simplifies the setup and management of distributed IN-MEMORY caching environments
  • Pay
    • Provisioned compute resources
    • Storage (charged according to compute resources)

Cache Engines

Engine Description
MEMCACHED
  • Allows to R/W objects into IN-MEMORY key/value data stores
  • Can elastically grow/shrink a cluster of nodes
  • Can PARTITION cluster into shards → parallel operations
  • OBJECT = BLOB (serialised results from a DB query) retrieved with a unique key
REDIS
  • OBJECT support + data types (string, list, set)
  • Can PERSIST in-memory data onto disk → allows to create snapshots that back up data & then recover/replicate from backups
  • Can SORT and RANK data
  • Can leverage PUB/SUB messaging abstraction

Operations

Node Types
  • Derived from subset of EC2 instance type
  • T2 = development & occasional bursts
  • M3 = good mix
  • T3 = memory-intensive workloads
Autodiscovery
  • For MEMCACHED clusters partitioned across multiple nodes
  • Gives apps the ability to identify automatically all nodes in the cluster
  • Works with scaling

Scaling

HORIZONTAL
  • MEMCACHED
    • Add more nodes
    • <= 20 nodes in a cluster
  • REDIS
    • 1! node but 1+ clusters can be grouped into a REPLICATION GROUP
    • 1! node handling W commands
    • <= 5 READ REPLICAS handling R-only requests
VERTICAL
  • You can't change node type
  • You can spin up a new cluster with desired node type & redirect traffic to new cluster
  • State at startup
    • MEMCACHED = always starts empty
    • REDIS = can be initialised from backup
Replication
  • Performed asynchronously
  • Goals
    • Rapid recovery of node failure
    • Serve high volumes of reads
  • MEMCACHED
    • Standalone in-memory services
    • No redundant data protection services
  • REDIS
    • Supports both goals with replication groups
    • Multi-AZ Replication Groups
      • Allow to increase availability and minimise loss of data
      • Failure of primary node → read replica promoted to new primary + new node provisioned to replace the failed one + update DNS of new primary
Backup
  • MEMCACHED
    • Snapshots cannot be created
  • REDIS
    • Allows to persist data on disk & to create a snapshot
    • SNAPSHOT = full clone of the data, stored in S3
    • AUTOMATIC = setup a replication group & perform snapshot against a read replica
    • MANUAL = stored indefinitely until you delete them

Security

Access Control
  1. Restrict INBOUND network access
    • Using SGs
      • Control network access to cache cluster
      • By default network access is off
      • For apps to access the cluster → explicitly enable access in specific EC2 SG
    • When deployed in a VPC, each node will be issued a private IP address
    • Nodes can never be accessed from the Internet or from EC2 outside the VPC
  2. Further restrict at the SUBNET LEVEL via ACLs
  3. Access to manage the config of the cluster is controlled separately (via IAM) from access to the actual memcached/redis service endpoint
Back to top