SlideShare a Scribd company logo
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
AWS re:INVENT
Amazon ElastiCache Deep Dive:
Best Practices and Usage Patterns
M i c h a e l L a b i b , N o S Q L S p e c i a l i s t S A , A W S
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
What to expect from this session
• Amazon ElastiCache overview
• Scaling your cluster with online re-sharding
• Amazon ElastiCache security and encryption
• Amazon ElastiCache usage patterns
• Best practices
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Amazon
ElastiCache
µs is the new ms
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
In-memory key-value store supporting
• Redis 3.2.10
• Memcached 1.4.34
High-performance
Fully managed; zero admin
Highly available and reliable
Hardened by Amazon
Amazon
ElastiCache
Request rate
High Low
Latency
Low High
Structure
Low
High
Data volume
Low High
Amazon
RDS
Amazon S3
Amazon
Glacier
Amazon
CloudSearch and
Amazon Elasticsearch
Service
Amazon
DynamoDB
Amazon
ElastiCache
and Amazon
DynamoDB
Accelerator
(DAX)
HDFS
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Powerful
~200 commands + Lua scripting
In-memory data structure server
Utility data structures
Strings, lists, hashes, sets, sorted sets,
bitmaps, and HyperLogLogs
Simple
Atomic operations
supports transactions
Ridiculously fast!
<1 ms latency for most commands
Highly available
replication
Persistence
Open source
Redis overview
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
But wait, there’s more!
Run Lua scripts Geospatial queries Pub/sub
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
SMEMBERS features
REDIS:6379>
Amazon
ElastiCache
1) “Easy to deploy & monitor”
AWS
Config
Amazon
CloudWatch
AWS
CloudTrail
AWS
CloudFormation
AWS
Management
Console
AWS CLI
and SDKs
alarm
REDIS:6379>
hget feature:details “deploy-monitor”
Amazon
SNS
Email
Notification
AWS
Lambda
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
SMEMBERS features
REDIS:6379>
REDIS:6379>
hget feature:details “enhancements”
2) “Enhanced Redis Engine”
Optimized Swap Memory
•Mitigate the risk of increased swap usage
during syncs and snapshots
Dynamic write throttling
•Improved output buffer management when
the node’s memory is close to being
exhausted
Smoother failovers
•Clusters recover faster as replicas avoid
flushing their data to do a full re-sync with
the primary
Amazon
ElastiCache
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
SMEMBERS ec-team:open-source:contributorsREDIS:6379>
https://raw.githubusercontent.com/antirez/redis/2.8/00-RELEASENOTES
(from https://github.com/antirez/redis/issues/1814)
1) “Kevin McGehee”
2) “Qu Chen”
3) “Rajib Dugar”
hgetall ec-team:open-source:contributionsREDIS:6379>
1) PSYNC2 (Redis 4.0)
https://raw.githubusercontent.com/antirez/redis/4.0/00-RELEASENOTES
3) BGSAVE (Redis 3.2)
https://raw.githubusercontent.com/antirez/redis/3.2/00-RELEASENOTES
5) MIGRATE (Redis 3.0)
7) MASTER TIMEOUT (Redis 2.8)
https://raw.githubusercontent.com/antirez/redis/3.0/00-RELEASENOTES
https://raw.githubusercontent.com/antirez/redis/2.8/00-RELEASENOTES
9) INCREASE 2Billion+ KEYS in a DATASET (Redis 2.8)
2)
4)
6)
8)
10)
Amazon
ElastiCache
11) also: 4114, 4250, 3926, 3899
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Slot 0-5461
Cluster Mode Disabled
Keyspace
Slot 10923-16383
I Primary 0–5 Replicas
Cluster Mode Enabled
Primary Endpoint
1–15 Primaries/Shards
Slot 0
Slot 5462-10922
Slot 16383
Keyspace
0–5 Replicas
Configuration Endpoint
Slot 1 …
Vertically Scaled
Horizontally Scaled
Max Storage 407 GiB
Max Storage 6+ TiB
Redis topologies
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Feature Enabled Disabled
Failover 15–30 sec
(Non-DNS)
~1.5 min
(DNS-based)
Failover risk • Writes affected—partial dataset (less risk with
more partitions)
• Reads available
• Writes affected on entire dataset
• Reads available
Performance Scales with cluster size
(90 nodes—15 primaries + 0–5 replicas per shard)
6 nodes (1 primary + 0–5 replicas)
Max connections • Primaries (65,000 x 15 = 975,000)
• Replicas (65,000 x 75 = 4,875,000)
• Primary: 65,000
• Replicas: (65,000 x 5 = 325,000)
Storage 6+ TiB 407 GB
Cost
Example: Assume
workload needs 175 GB
Smaller nodes but more $$
9 x cache.r3.xlarge ($0.455hr) = $4.095 hr 255.6 GB
Larger nodes less $
1 X cache.r3.8xlarge = $3.640, 237 GB
Redis cluster-mode enabled vs. disabled
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Closer look at cluster-mode enabled
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
S5
S1
S2
S4 S3
Client
 16384 hash slots per cluster
 Slot for a key is CRC16(key) mod 16384
 Slots are distributed across the cluster into shards
 Developers must use a Redis cluster aware client
 Clients are redirected to the correct shard
 Smart clients store a map
Shard S1 = slots 0–3276
Shard S2 = slots 3277–6553
Shard S3 = slots 6554–9829
Shard S4 = slots 9830–13106
Shard S5 = slots 13107–16383
Redis cluster: automatic client-side sharding
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Availability Zone A
slots 0–5454 slots 5455–10909
Redis Cluster
Redis cluster—architecture
slots 10910–16363
Availability Zone B Availability Zone C
slots 5455–10909
slots 5455–10909slots 0–5454 slots 0–5454
slots 10910–16363
slots 10910–16363
Redis cluster—multi-AZ
A cluster consists of 1 to 15 shards
Example: 3-shard cluster,
2 read replicas
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Availability Zone A
slots 0–5454
Redis Cluster
Redis cluster—architecture
slots 10910–16363
Availability Zone B Availability Zone C
slots 5455–10909
slots 5455–10909slots 0–5454 slots 0–5454
slots 10910–16363
Shard
ReplicaReplicaPrimary
Each shard has a primary node
and up to five replica nodes
slots 5455–10909
slots 10910–16363
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Availability Zone A
slots 0–5454 slots 5455–10909
Redis Cluster
Redis cluster—architecture
slots 10910–16363
Availability Zone B Availability Zone C
slots 5455–10909
slots 5455–10909
Shard
ReplicaReplica Primary
Each shard has a primary node
and up to five replica nodes
slots 0–5454 slots 0–5454
slots 10910–16363
slots 10910–16363
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Availability Zone A
slots 0–5454
Redis Cluster
Redis cluster—architecture
slots 10910–16363
Availability Zone B Availability Zone C
slots 10910–16363
slots 10910–16363
Shard
Replica PrimaryReplica
Each shard has a primary node
and up to five replica nodes
slots 5455–10909 slots 0–5454
slots 5455–10909
slots 0–5454 slots 5455–10909
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Availability Zone A
slots 0–5454 slots 5455–10909
Redis Cluster
slots 10910–16363
Availability Zone B Availability Zone C
slots 5455–10909 slots 5455–10909slots 0–5454 slots 0–5454
slots 10910–16363 slots 10910–16363
Scenario 1: Single primary failure
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Availability Zone A
slots 0–5454 slots 5455–10909
Redis Cluster
Scenario 1: Single primary failure
slots 10910–16363
Availability Zone B Availability Zone C
slots 5455–10909 slots 5455–10909slots 0–5454 slots 0–5454
slots 10910–16363
Mitigation:
1. Automatic failure detection and replica promotion (~15–30 s)
2. Repair failed node
slots 10910–16363
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Availability Zone A
slots 0–5454 slots 5455–10909
Redis Cluster
Scenario 2: Majority of primaries fail
slots 10910–16363
Availability Zone B Availability Zone C
slots 5455–10909 slots 5455–10909slots 0–5454 slots 0–5454
slots 10910–16363slots 10910–16363
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Availability Zone A
slots 0–5454 slots 5455–10909
Redis Cluster
slots 10910–16363
Availability Zone B Availability Zone C
slots 5455–10909 slots 5455–10909slots 0–5454 slots 0–5454
Mitigation: Redis enhancements on ElastiCache
• Automatic failure detection and replica promotion
• Repair failed nodes
slots 10910–16363slots 10910–16363
Scenario 2: Majority of primaries fail
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
aws elasticache create-snapshot --replication-group-id redisclusterID --snapshot-name snameStep 1
aws elasticache copy-snapshot --source-snapshot-name sname --target-snapshot-name sname
--target-bucket s3ucketname
Step 2
Step 3 aws elasticache create-replication-group --replication-group-id NewRedisClusterID … --snapshot-arns
arn:aws:s3:::bucketname/redisbackup-0001.rdb, etc.
Step 4 Once the new cluster is up, update your app with new Amazon ElastiCache endpoint, then terminate old cluster
3 Shards 5 Shards
Downtime
New writes
not in
snapshot
rdb
Pro tip: DR strategy—enable
CRR on Amazon S3 bucket
triggering AWS Lambda function
to hydrate destination cluster
Resizing via backup and restore
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Zero-downtime Online Re-sharding
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
0-5461
Shard 1 Shard 2 Shard 3
5462--10922 10923-16383
aws elasticache modify-replication-group-shard-configuration --replication-group-id rep-group-id
--apply-immediately --node-group-count 5
Simple API
Scale In || Out
Online Re-Sharding—zero downtime
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
0-5461
reads/writes
Shard 1 Shard 2 Shard 3
Shard 4 Shard 5
5462--10922 10923-163830-2909,
5095-5461
5462-5783,
6876-9830
10923-14199
2910-5094,
9831--10922
No application interruption
Uniform slot distribution across shards
5784-6875,
14200-16383
Online Re-Sharding—zero downtime: Scale Out
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
0-5461
reads/writes
Shard 1 Shard 2 Shard 3
Shard 4 Shard 5
5462--10922 10923-16383
Uniform slot distribution across shards
No Application Interruption
Online Re-Sharding—zero downtime: Scale In
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
AWS Lambda
3 Shards
…
var params = {
ApplyImmediately: true,
NodeGroupCount: 5,
ReplicationGroupId: ‘rep-group-id’,
… }
elasticache.modifyReplicationGroupShardConfiguration(params, function(err, data) {
if (err) console.log(err, err.stack);
else console.log(data);
}); …
5 Shards
MEMORY
HIGH!
Amazon
CloudWatch
Cluster Resized
AWS SNS
Online Re-Sharding—CW alarm triggered
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
reads/
writes
reads
AZ1
AZ2
reads
search
reads
search
clients
c a c h e c l u s t e r
r e l a t i o n a l
d a t a
Healthy
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
reads/
writes
reads
AZ1
AZ2
reads
search
reads
search
clients
c a c h e c l u s t e r
r e l a t i o n a l
d a t a
Heavy
pressure
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
reads/
writes
reads
AZ1
AZ2
reads
search
reads
search
c a c h e c l u s t e r
clients
r e l a t i o n a l
d a t a
Healthy—
auto scaled
out
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Amazon ElastiCache security
ElastiCache Redis reference architecture
Availability Zone B Availability Zone CAvailability Zone A
REDIS:6379> hget feature:details “ref-arch”
ElastiCache Redis Reference Architecture
Availability Zone B Availability Zone CAvailability Zone A
Private SubnetPrivate Subnet Private Subnet
REDIS:6379> hget feature:details “ref-arch”
ElastiCache Redis Reference Architecture
Availability Zone B Availability Zone CAvailability Zone A
Private SubnetPrivate Subnet Private Subnet
REDIS:6379> hget feature:details “ref-arch”
security group security group security group
ElastiCache Redis Reference Architecture
Availability Zone B Availability Zone CAvailability Zone A
Private SubnetPrivate Subnet Private Subnet
REDIS:6379> hget feature:details “ref-arch”
security group security group security group
ElastiCache Redis Cluster
Amazon S3
bucket
REDIS RDB
snapshot
Encryption at
REST
ElastiCache Redis Reference Architecture
Availability Zone B Availability Zone CAvailability Zone A
Private SubnetPrivate Subnet Private Subnet
REDIS:6379> hget feature:details “ref-arch”
security group security group security group
ElastiCache Redis Cluster
security group
Public Subnet
security group
Public Subnet Public Subnet
Amazon S3
bucket
REDIS RDB
snapshot
security group
Encryption In-Transit 3.2.6 Redis AUTH
Encryption at
REST
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Encryption
• In-Transit: encrypt all communications between clients
and Redis server as well as between nodes
• At-Rest: encrypt backups on disk and in Amazon S3
• Fully managed: setup via API or console, automatic
issuance and renewal
Compliance
• HIPAA eligibility for ElastiCache for Redis
• Included in AWS Business Associate Addendum
• Redis 3.2.6
Amazon ElastiCache Encryption and Compliance
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Common usage patterns
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Session
management
Database caching APIs
(HTTP responses)
IOT
Streaming data
analytics
(Filtering/aggregation)
Pub/sub
Social media
(Sentiment analysis)
Standalone
database
(Metadata store)
Leaderboards
Usage patterns
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Caching
Clients
Amazon
ElastiCache
Redis
Amazon
DynamoDB
Elastic Load
Balancing
Amazon
EC2
Amazon
RDS
write-through
reads/
writes
DDB streams
mysql.lambda_async
reads/
writes
Amazon
S3
reads/writes
Object data
Unstructured data
Relational data
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Caching NoSQL
Amazon
EC2 reads/
writes
reads
MongoDB
Cluster
Cassandra
Cluster
 Smaller NoSQL DB clusters needed = lower costs
 Faster data retrieval = better performance
Elasticsearch
Cluster
Clients
Amazon
EC2
reads/
writes
Amazon
ElastiCache
Redis
reads
MongoDB
Cluster
DBObject doc = collection.findOne();
Cache serialized DBObject in Redis (good)
Cache rows in Redis hash (faster/more efficient)
Cassandra
Cluster
Amazon
ElastiCache
Redis
Amazon
EC2
reads/
writes
reads
ResultSet rs = session.execute(stmt);
Cache serialized ResultSet in Redis (good)
Cache rows in Redis hash (faster/more efficient)
 Smaller NoSQL DB clusters needed = lower costs
 Faster data retrieval = better performance
Caching NoSQL databases with Amazon ElastiCache
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Amazon
Kinesis
Analytics
Amazon
Kinesis
Streams
Amazon
Kinesis
Streams
Amazon
ElastiCache
(Redis)
cleansed
stream
Streaming data enrichment/processing
Datasources
raw
stream
Subscribers
AWS Lambda function 1
Continual data
filtering/enrichment
Real-time
pub/sub
AWS Lambda function 2
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Big data architectures using Redis
Amazon Kinesis
DataSources
AWS Lambda
Apache Storm
on EMR
Spark Streaming
on Amazon EMR
Amazon
Kinesis app
Amazon
EC2
AWS IoT
Amazon
ElastiCache
Collect
Store
Process
Amazon
S3
Apache Kafka
AWS
Lambda
Custom
app
Spark on
Amazon
EMR
Analyze
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Rules Engine
Amazon
ElastiCache
Redis
AWS
Lambda
Direct integration
LambdaSNS SQS
S3 KinesisDDB
AWS
IoT devices
AWS
IoT
Sensor store
IoT powered by ElastiCache
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Mobile apps powered by ElastiCache
Amazon API
Gateway
AWS
Lambda
Amazon
ElastiCache
Redis
GEOADD
GEORADIUS
Search points of interest
Update points of interest
https://aws.amazon.com/blogs/database/amazon-elasticache-utilizing-redis-geospatial-capabilities/
Amazon
DynamoDB
DDB streams
Amazon
EC2
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Ad tech powered by ElastiCache
Clients
Advertisers
https://aws.amazon.com/caching/database-caching/
Ad network
Ad slot
Consumer
Ad slot
publishers
Ad placement
(websites/apps)
Amazon
ElastiCache
Redis
<40 ms
Clickstream
(shopping
events)
User visits
page
Publisher
places ad slot
for auction
Ad network
calls for bidsBidders respond
with bids
Winners bid
ad displayed
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Chat apps powered by ElastiCache
https://aws.amazon.com/blogs/database/amazon-elasticache-utilizing-redis-geospatial-capabilities/
Clients
Chat apps
Application Load
Balancer
WebSockets
Amazon
ElastiCache
Redis
PubSub
Serverpersistent
connections
Elastic
Beanstalk
SUBSCRIBE chat_channel:114
PUBLISH chat_channel:114 "Hello all"
>> ["message", "chat_channel:114", "Hello all"]
UNSUBSCRIBE chat_channel:114
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
• Very popular for gaming apps that need
uniqueness and ordering
• Easy with Redis sorted sets
ZADD "leaderboard" 1201 "Gollum”
ZADD "leaderboard" 963 "Sauron"
ZADD "leaderboard" 1092 "Bilbo"
ZADD "leaderboard" 1383 "Frodo”
ZREVRANGE "leaderboard" 0 -1
1) "Frodo"
2) "Gollum"
3) "Bilbo"
4) "Sauron”
ZREVRANK "leaderboard" "Sauron"
(integer) 3
Gaming—real-time leaderboards
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Ex: throttling requests to an API
uses Redis counters
ELB
Externally
facing API
Reference: http://redis.io/commands/INCR
FUNCTION LIMIT_API_CALL(APIaccesskey)
limit = HGET(APIaccesskey, “limit”)
time = CURRENT_UNIX_TIME()
keyname = APIaccesskey + ":” + time
count = GET(keyname)
IF current != NULL && count > limit THEN
ERROR ”API request limit exceeded"
ELSE
MULTI
INCR(keyname)
EXPIRE(keyname,10)
EXEC
PERFORM_API_CALL()
END
Rate limiting
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Amazon ElastiCache: Best practices
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Cluster sizing best practices
• Storage—clusters should have adequate memory
• Recommended: memory needed + 25% reserved memory (for Redis) + some room for growth
(optional 10%)
• Optimize using eviction policies and TTLs
• Scale up or out before reaching max-memory using CloudWatch alarms
• Use memory optimized nodes for cost effectiveness (R4 support)
• Performance—performance should not be compromised
• Benchmark operations using Redis Benchmark tool
• For more READIOPS—add replicas
• For more WRITEIOPS—add shards (scale out)
• For more network IO—use network optimized instances and scale out
• Use pipelining for bulk reads/writes
• Consider Big(O) time complexity for data structure commands
• Cluster isolation (apps sharing key space)—choose a strategy that works for your workload
• Identify what kind of isolation is needed based on the workload and environment
• Isolation: No Isolation $ | Isolation by Purpose $$ | Full Isolation $$$
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Redis benchmark tool
Open source utility to benchmark performance
example: src/redis-benchmark -h r3-xlarge-perf.foio87.0001.use1.cache.amazonaws.com -p 6379 -n -150000 -d 100
Syntax:
redis-benchmark -h <host> -p <port> -c 50 -n 1000 -d 500 –q
-c <clients>—Specifies the number of parallel connections (default 50).
-n <requests>—Specifies the number of requests (default 1000000).
-d <size>—Specifies the data size of GET and SET values in bytes.
-t <test1,test2>—Comma-separated list of tests to perform.
-q—Quiet operation, displays only the result.
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Redis max-memory policies
Select a max-memory policy based on your workload needs
• noeviction: return errors when the memory limit has been reached and the client is trying to execute
commands that might result in more memory to be used
• allkeys-lru: evict keys trying to remove the less recently used (LRU) keys first
• volatile-lru: evict keys trying to remove the less recently used (LRU) keys first, but only among keys
that have an expire set
• allkeys-random: evict random keys to make space for the new data added
• volatile-random: evict random keys to make space for the new data added, but only evict keys with an
expire set
• volatile-ttl: evict only keys with an expire set, and try to evict keys with a shorter time to live (TTL) first
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Key ElastiCache CloudWatch metrics
• CPUUtilization
• Memcached—up to 90% ok
• Redis—divide by cores (ex: 90% / 4 = 22.5%)
• SwapUsage low
• CacheMisses/CacheHits Ratio low/stable
• Evictions near zero
• Exception: Russian-doll caching
• CurrConnections stable
• Setup alarms with CloudWatch metrics
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
ElastiCache modifiable parameters
• Maxclients: 65000 (unchangeable)
• Use connection pooling
• timeout—closes a connection after it has been idle for a given interval
• tcp-keepalive—detects dead peers given an interval
• Databases: 16 (default) for non-clustered mode
• Logical partition
• Reserved-memory: 25% (default)
• Recommended
 50% of maxmemory to use before 2.8.22
 25% after 2.8.22—ElastiCache
• Maxmemory-policy:
• The eviction policy for keys when maximum memory usage is reached
• Possible values: volatile-lru, allkeys-lru, volatile-random, allkeys-random, volatile-ttl,
noeviction
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
• Understand the frequency of change of underlying data
• Set appropriate TTLs on keys that match that frequency
• Choose appropriate eviction policies that are aligned with application requirements
• Isolate your cluster by purpose (for example, cache cluster, queue, standalone database, and so on)
• Maintain cache freshness with write-throughs
• Performance test and size your cluster appropriately
• Monitor Cache HIT/MISS ratio and alarm on poor performance
• Use failover API to test application resiliency
Caching tips
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Thank you!

More Related Content

What's hot

Introduction to Redis
Introduction to RedisIntroduction to Redis
Introduction to Redis
Dvir Volk
 
Elastic Load Balancing Deep Dive - AWS Online Tech Talk
Elastic  Load Balancing Deep Dive - AWS Online Tech TalkElastic  Load Balancing Deep Dive - AWS Online Tech Talk
Elastic Load Balancing Deep Dive - AWS Online Tech Talk
Amazon Web Services
 
Introduction to Amazon Elastic File System (EFS)
Introduction to Amazon Elastic File System (EFS)Introduction to Amazon Elastic File System (EFS)
Introduction to Amazon Elastic File System (EFS)
Amazon Web Services
 
다양한 배포 기법과 AWS에서 구축하는 CI/CD 파이프라인 l 안효빈 솔루션즈 아키텍트
다양한 배포 기법과 AWS에서 구축하는 CI/CD 파이프라인 l 안효빈 솔루션즈 아키텍트다양한 배포 기법과 AWS에서 구축하는 CI/CD 파이프라인 l 안효빈 솔루션즈 아키텍트
다양한 배포 기법과 AWS에서 구축하는 CI/CD 파이프라인 l 안효빈 솔루션즈 아키텍트
Amazon Web Services Korea
 
K8s on AWS - Introducing Amazon EKS
K8s on AWS - Introducing Amazon EKSK8s on AWS - Introducing Amazon EKS
K8s on AWS - Introducing Amazon EKS
Amazon Web Services
 
AWS re:Invent 2016: Workshop: Choose Your Own SAML Adventure: A Self-Directed...
AWS re:Invent 2016: Workshop: Choose Your Own SAML Adventure: A Self-Directed...AWS re:Invent 2016: Workshop: Choose Your Own SAML Adventure: A Self-Directed...
AWS re:Invent 2016: Workshop: Choose Your Own SAML Adventure: A Self-Directed...
Amazon Web Services
 
AWS Webcast - Introduction to EBS
AWS Webcast - Introduction to EBS AWS Webcast - Introduction to EBS
AWS Webcast - Introduction to EBS
Amazon Web Services
 
Introduction to Apache ZooKeeper
Introduction to Apache ZooKeeperIntroduction to Apache ZooKeeper
Introduction to Apache ZooKeeper
Saurav Haloi
 
Migrating Your Databases to AWS - Deep Dive on Amazon RDS and AWS Database Mi...
Migrating Your Databases to AWS - Deep Dive on Amazon RDS and AWS Database Mi...Migrating Your Databases to AWS - Deep Dive on Amazon RDS and AWS Database Mi...
Migrating Your Databases to AWS - Deep Dive on Amazon RDS and AWS Database Mi...
Amazon Web Services
 
Apache Kafka Best Practices
Apache Kafka Best PracticesApache Kafka Best Practices
Apache Kafka Best Practices
DataWorks Summit/Hadoop Summit
 
Scaling production grade EKS Multi-Cluster environments using GitOps
Scaling production grade EKS Multi-Cluster environments using GitOpsScaling production grade EKS Multi-Cluster environments using GitOps
Scaling production grade EKS Multi-Cluster environments using GitOps
Carlos Santana
 
AWS Storage Services - AWS Presentation - AWS Cloud Storage for the Enterpris...
AWS Storage Services - AWS Presentation - AWS Cloud Storage for the Enterpris...AWS Storage Services - AWS Presentation - AWS Cloud Storage for the Enterpris...
AWS Storage Services - AWS Presentation - AWS Cloud Storage for the Enterpris...
Amazon Web Services
 
AI & AWS DeepComposer
AI & AWS DeepComposerAI & AWS DeepComposer
AI & AWS DeepComposer
Amazon Web Services
 
Introduction to Amazon Aurora
Introduction to Amazon AuroraIntroduction to Amazon Aurora
Introduction to Amazon Aurora
Amazon Web Services
 
Introduction to Google Cloud Platform
Introduction to Google Cloud PlatformIntroduction to Google Cloud Platform
Introduction to Google Cloud Platform
Opsta
 
컴플라이언스를 위한 고급 AWS 보안 구성 방법-AWS Summit Seoul 2017
컴플라이언스를 위한 고급 AWS 보안 구성 방법-AWS Summit Seoul 2017컴플라이언스를 위한 고급 AWS 보안 구성 방법-AWS Summit Seoul 2017
컴플라이언스를 위한 고급 AWS 보안 구성 방법-AWS Summit Seoul 2017
Amazon Web Services Korea
 
AWS Security Best Practices in a Zero Trust Security Model - DEM08 - Toronto ...
AWS Security Best Practices in a Zero Trust Security Model - DEM08 - Toronto ...AWS Security Best Practices in a Zero Trust Security Model - DEM08 - Toronto ...
AWS Security Best Practices in a Zero Trust Security Model - DEM08 - Toronto ...
Amazon Web Services
 
Behind the Scenes: Exploring the AWS Global Network (NET305) - AWS re:Invent ...
Behind the Scenes: Exploring the AWS Global Network (NET305) - AWS re:Invent ...Behind the Scenes: Exploring the AWS Global Network (NET305) - AWS re:Invent ...
Behind the Scenes: Exploring the AWS Global Network (NET305) - AWS re:Invent ...
Amazon Web Services
 
AWS Multi-Account Architecture and Best Practices
AWS Multi-Account Architecture and Best PracticesAWS Multi-Account Architecture and Best Practices
AWS Multi-Account Architecture and Best Practices
Amazon Web Services
 
IBM Spectrum Scale and Its Use for Content Management
 IBM Spectrum Scale and Its Use for Content Management IBM Spectrum Scale and Its Use for Content Management
IBM Spectrum Scale and Its Use for Content Management
Sandeep Patil
 

What's hot (20)

Introduction to Redis
Introduction to RedisIntroduction to Redis
Introduction to Redis
 
Elastic Load Balancing Deep Dive - AWS Online Tech Talk
Elastic  Load Balancing Deep Dive - AWS Online Tech TalkElastic  Load Balancing Deep Dive - AWS Online Tech Talk
Elastic Load Balancing Deep Dive - AWS Online Tech Talk
 
Introduction to Amazon Elastic File System (EFS)
Introduction to Amazon Elastic File System (EFS)Introduction to Amazon Elastic File System (EFS)
Introduction to Amazon Elastic File System (EFS)
 
다양한 배포 기법과 AWS에서 구축하는 CI/CD 파이프라인 l 안효빈 솔루션즈 아키텍트
다양한 배포 기법과 AWS에서 구축하는 CI/CD 파이프라인 l 안효빈 솔루션즈 아키텍트다양한 배포 기법과 AWS에서 구축하는 CI/CD 파이프라인 l 안효빈 솔루션즈 아키텍트
다양한 배포 기법과 AWS에서 구축하는 CI/CD 파이프라인 l 안효빈 솔루션즈 아키텍트
 
K8s on AWS - Introducing Amazon EKS
K8s on AWS - Introducing Amazon EKSK8s on AWS - Introducing Amazon EKS
K8s on AWS - Introducing Amazon EKS
 
AWS re:Invent 2016: Workshop: Choose Your Own SAML Adventure: A Self-Directed...
AWS re:Invent 2016: Workshop: Choose Your Own SAML Adventure: A Self-Directed...AWS re:Invent 2016: Workshop: Choose Your Own SAML Adventure: A Self-Directed...
AWS re:Invent 2016: Workshop: Choose Your Own SAML Adventure: A Self-Directed...
 
AWS Webcast - Introduction to EBS
AWS Webcast - Introduction to EBS AWS Webcast - Introduction to EBS
AWS Webcast - Introduction to EBS
 
Introduction to Apache ZooKeeper
Introduction to Apache ZooKeeperIntroduction to Apache ZooKeeper
Introduction to Apache ZooKeeper
 
Migrating Your Databases to AWS - Deep Dive on Amazon RDS and AWS Database Mi...
Migrating Your Databases to AWS - Deep Dive on Amazon RDS and AWS Database Mi...Migrating Your Databases to AWS - Deep Dive on Amazon RDS and AWS Database Mi...
Migrating Your Databases to AWS - Deep Dive on Amazon RDS and AWS Database Mi...
 
Apache Kafka Best Practices
Apache Kafka Best PracticesApache Kafka Best Practices
Apache Kafka Best Practices
 
Scaling production grade EKS Multi-Cluster environments using GitOps
Scaling production grade EKS Multi-Cluster environments using GitOpsScaling production grade EKS Multi-Cluster environments using GitOps
Scaling production grade EKS Multi-Cluster environments using GitOps
 
AWS Storage Services - AWS Presentation - AWS Cloud Storage for the Enterpris...
AWS Storage Services - AWS Presentation - AWS Cloud Storage for the Enterpris...AWS Storage Services - AWS Presentation - AWS Cloud Storage for the Enterpris...
AWS Storage Services - AWS Presentation - AWS Cloud Storage for the Enterpris...
 
AI & AWS DeepComposer
AI & AWS DeepComposerAI & AWS DeepComposer
AI & AWS DeepComposer
 
Introduction to Amazon Aurora
Introduction to Amazon AuroraIntroduction to Amazon Aurora
Introduction to Amazon Aurora
 
Introduction to Google Cloud Platform
Introduction to Google Cloud PlatformIntroduction to Google Cloud Platform
Introduction to Google Cloud Platform
 
컴플라이언스를 위한 고급 AWS 보안 구성 방법-AWS Summit Seoul 2017
컴플라이언스를 위한 고급 AWS 보안 구성 방법-AWS Summit Seoul 2017컴플라이언스를 위한 고급 AWS 보안 구성 방법-AWS Summit Seoul 2017
컴플라이언스를 위한 고급 AWS 보안 구성 방법-AWS Summit Seoul 2017
 
AWS Security Best Practices in a Zero Trust Security Model - DEM08 - Toronto ...
AWS Security Best Practices in a Zero Trust Security Model - DEM08 - Toronto ...AWS Security Best Practices in a Zero Trust Security Model - DEM08 - Toronto ...
AWS Security Best Practices in a Zero Trust Security Model - DEM08 - Toronto ...
 
Behind the Scenes: Exploring the AWS Global Network (NET305) - AWS re:Invent ...
Behind the Scenes: Exploring the AWS Global Network (NET305) - AWS re:Invent ...Behind the Scenes: Exploring the AWS Global Network (NET305) - AWS re:Invent ...
Behind the Scenes: Exploring the AWS Global Network (NET305) - AWS re:Invent ...
 
AWS Multi-Account Architecture and Best Practices
AWS Multi-Account Architecture and Best PracticesAWS Multi-Account Architecture and Best Practices
AWS Multi-Account Architecture and Best Practices
 
IBM Spectrum Scale and Its Use for Content Management
 IBM Spectrum Scale and Its Use for Content Management IBM Spectrum Scale and Its Use for Content Management
IBM Spectrum Scale and Its Use for Content Management
 

Similar to DAT305_Amazon ElastiCache Deep Dive

Unleash the Power of Redis with Amazon ElastiCache
Unleash the Power of Redis with Amazon ElastiCacheUnleash the Power of Redis with Amazon ElastiCache
Unleash the Power of Redis with Amazon ElastiCache
Amazon Web Services
 
Scaling Redis Workloads with Amazon ElastiCache - AWS Online Tech Talks
Scaling Redis Workloads with Amazon ElastiCache - AWS Online Tech TalksScaling Redis Workloads with Amazon ElastiCache - AWS Online Tech Talks
Scaling Redis Workloads with Amazon ElastiCache - AWS Online Tech Talks
Amazon Web Services
 
DAT341_Working with Amazon ElastiCache for Redis
DAT341_Working with Amazon ElastiCache for RedisDAT341_Working with Amazon ElastiCache for Redis
DAT341_Working with Amazon ElastiCache for Redis
Amazon Web Services
 
ElastiCache and Redis
ElastiCache and RedisElastiCache and Redis
ElastiCache and Redis
Amazon Web Services
 
Amazon ElastiCache and Redis
Amazon ElastiCache and RedisAmazon ElastiCache and Redis
Amazon ElastiCache and Redis
Amazon Web Services
 
RedisConf17 - Turbo-charge your apps with Amazon Elasticache for Redis
RedisConf17 - Turbo-charge your apps with Amazon Elasticache for RedisRedisConf17 - Turbo-charge your apps with Amazon Elasticache for Redis
RedisConf17 - Turbo-charge your apps with Amazon Elasticache for Redis
Redis Labs
 
Amazon Elasticache Deep Dive - March 2017 AWS Online Tech Talks
Amazon Elasticache Deep Dive - March 2017 AWS Online Tech TalksAmazon Elasticache Deep Dive - March 2017 AWS Online Tech Talks
Amazon Elasticache Deep Dive - March 2017 AWS Online Tech Talks
Amazon Web Services
 
ElastiCache Deep Dive: Best Practices and Usage Patterns - March 2017 AWS Onl...
ElastiCache Deep Dive: Best Practices and Usage Patterns - March 2017 AWS Onl...ElastiCache Deep Dive: Best Practices and Usage Patterns - March 2017 AWS Onl...
ElastiCache Deep Dive: Best Practices and Usage Patterns - March 2017 AWS Onl...
Amazon Web Services
 
Amazon Elasticache and Redis
Amazon Elasticache and RedisAmazon Elasticache and Redis
Amazon Elasticache and Redis
Mikhail Prudnikov
 
ElastiCache: Deep Dive Best Practices and Usage Patterns - AWS Online Tech Talks
ElastiCache: Deep Dive Best Practices and Usage Patterns - AWS Online Tech TalksElastiCache: Deep Dive Best Practices and Usage Patterns - AWS Online Tech Talks
ElastiCache: Deep Dive Best Practices and Usage Patterns - AWS Online Tech Talks
Amazon Web Services
 
Hands-On with Amazon ElastiCache for Redis - Workshop (DAT309-R1) - AWS re:In...
Hands-On with Amazon ElastiCache for Redis - Workshop (DAT309-R1) - AWS re:In...Hands-On with Amazon ElastiCache for Redis - Workshop (DAT309-R1) - AWS re:In...
Hands-On with Amazon ElastiCache for Redis - Workshop (DAT309-R1) - AWS re:In...
Amazon Web Services
 
(BDT208) A Technical Introduction to Amazon Elastic MapReduce
(BDT208) A Technical Introduction to Amazon Elastic MapReduce(BDT208) A Technical Introduction to Amazon Elastic MapReduce
(BDT208) A Technical Introduction to Amazon Elastic MapReduce
Amazon Web Services
 
ElastiCache Deep Dive: Design Patterns for In-Memory Data Stores (DAT302-R1) ...
ElastiCache Deep Dive: Design Patterns for In-Memory Data Stores (DAT302-R1) ...ElastiCache Deep Dive: Design Patterns for In-Memory Data Stores (DAT302-R1) ...
ElastiCache Deep Dive: Design Patterns for In-Memory Data Stores (DAT302-R1) ...
Amazon Web Services
 
GAM307_Ubisoft How For Honor Runs Using Amazon ECS
GAM307_Ubisoft How For Honor Runs Using Amazon ECSGAM307_Ubisoft How For Honor Runs Using Amazon ECS
GAM307_Ubisoft How For Honor Runs Using Amazon ECS
Amazon Web Services
 
Fast Data at Scale - AWS Summit Tel Aviv 2017
Fast Data at Scale - AWS Summit Tel Aviv 2017Fast Data at Scale - AWS Summit Tel Aviv 2017
Fast Data at Scale - AWS Summit Tel Aviv 2017
Amazon Web Services
 
Using Databases and Containers From Development to Deployment
Using Databases and Containers  From Development to DeploymentUsing Databases and Containers  From Development to Deployment
Using Databases and Containers From Development to Deployment
Aerospike, Inc.
 
SD Times - Docker v2
SD Times - Docker v2SD Times - Docker v2
SD Times - Docker v2
Alvin Richards
 
SRV308 Deep Dive on Amazon Aurora
SRV308 Deep Dive on Amazon AuroraSRV308 Deep Dive on Amazon Aurora
SRV308 Deep Dive on Amazon Aurora
Amazon Web Services
 
Architecting SAP on Amazon Web Services - SVC216 - Chicago AWS Summit
Architecting SAP on Amazon Web Services - SVC216 - Chicago AWS SummitArchitecting SAP on Amazon Web Services - SVC216 - Chicago AWS Summit
Architecting SAP on Amazon Web Services - SVC216 - Chicago AWS Summit
Amazon Web Services
 
STG330_Case Study How Experian Leverages Amazon EC2, EBS, and S3 with Clouder...
STG330_Case Study How Experian Leverages Amazon EC2, EBS, and S3 with Clouder...STG330_Case Study How Experian Leverages Amazon EC2, EBS, and S3 with Clouder...
STG330_Case Study How Experian Leverages Amazon EC2, EBS, and S3 with Clouder...
Amazon Web Services
 

Similar to DAT305_Amazon ElastiCache Deep Dive (20)

Unleash the Power of Redis with Amazon ElastiCache
Unleash the Power of Redis with Amazon ElastiCacheUnleash the Power of Redis with Amazon ElastiCache
Unleash the Power of Redis with Amazon ElastiCache
 
Scaling Redis Workloads with Amazon ElastiCache - AWS Online Tech Talks
Scaling Redis Workloads with Amazon ElastiCache - AWS Online Tech TalksScaling Redis Workloads with Amazon ElastiCache - AWS Online Tech Talks
Scaling Redis Workloads with Amazon ElastiCache - AWS Online Tech Talks
 
DAT341_Working with Amazon ElastiCache for Redis
DAT341_Working with Amazon ElastiCache for RedisDAT341_Working with Amazon ElastiCache for Redis
DAT341_Working with Amazon ElastiCache for Redis
 
ElastiCache and Redis
ElastiCache and RedisElastiCache and Redis
ElastiCache and Redis
 
Amazon ElastiCache and Redis
Amazon ElastiCache and RedisAmazon ElastiCache and Redis
Amazon ElastiCache and Redis
 
RedisConf17 - Turbo-charge your apps with Amazon Elasticache for Redis
RedisConf17 - Turbo-charge your apps with Amazon Elasticache for RedisRedisConf17 - Turbo-charge your apps with Amazon Elasticache for Redis
RedisConf17 - Turbo-charge your apps with Amazon Elasticache for Redis
 
Amazon Elasticache Deep Dive - March 2017 AWS Online Tech Talks
Amazon Elasticache Deep Dive - March 2017 AWS Online Tech TalksAmazon Elasticache Deep Dive - March 2017 AWS Online Tech Talks
Amazon Elasticache Deep Dive - March 2017 AWS Online Tech Talks
 
ElastiCache Deep Dive: Best Practices and Usage Patterns - March 2017 AWS Onl...
ElastiCache Deep Dive: Best Practices and Usage Patterns - March 2017 AWS Onl...ElastiCache Deep Dive: Best Practices and Usage Patterns - March 2017 AWS Onl...
ElastiCache Deep Dive: Best Practices and Usage Patterns - March 2017 AWS Onl...
 
Amazon Elasticache and Redis
Amazon Elasticache and RedisAmazon Elasticache and Redis
Amazon Elasticache and Redis
 
ElastiCache: Deep Dive Best Practices and Usage Patterns - AWS Online Tech Talks
ElastiCache: Deep Dive Best Practices and Usage Patterns - AWS Online Tech TalksElastiCache: Deep Dive Best Practices and Usage Patterns - AWS Online Tech Talks
ElastiCache: Deep Dive Best Practices and Usage Patterns - AWS Online Tech Talks
 
Hands-On with Amazon ElastiCache for Redis - Workshop (DAT309-R1) - AWS re:In...
Hands-On with Amazon ElastiCache for Redis - Workshop (DAT309-R1) - AWS re:In...Hands-On with Amazon ElastiCache for Redis - Workshop (DAT309-R1) - AWS re:In...
Hands-On with Amazon ElastiCache for Redis - Workshop (DAT309-R1) - AWS re:In...
 
(BDT208) A Technical Introduction to Amazon Elastic MapReduce
(BDT208) A Technical Introduction to Amazon Elastic MapReduce(BDT208) A Technical Introduction to Amazon Elastic MapReduce
(BDT208) A Technical Introduction to Amazon Elastic MapReduce
 
ElastiCache Deep Dive: Design Patterns for In-Memory Data Stores (DAT302-R1) ...
ElastiCache Deep Dive: Design Patterns for In-Memory Data Stores (DAT302-R1) ...ElastiCache Deep Dive: Design Patterns for In-Memory Data Stores (DAT302-R1) ...
ElastiCache Deep Dive: Design Patterns for In-Memory Data Stores (DAT302-R1) ...
 
GAM307_Ubisoft How For Honor Runs Using Amazon ECS
GAM307_Ubisoft How For Honor Runs Using Amazon ECSGAM307_Ubisoft How For Honor Runs Using Amazon ECS
GAM307_Ubisoft How For Honor Runs Using Amazon ECS
 
Fast Data at Scale - AWS Summit Tel Aviv 2017
Fast Data at Scale - AWS Summit Tel Aviv 2017Fast Data at Scale - AWS Summit Tel Aviv 2017
Fast Data at Scale - AWS Summit Tel Aviv 2017
 
Using Databases and Containers From Development to Deployment
Using Databases and Containers  From Development to DeploymentUsing Databases and Containers  From Development to Deployment
Using Databases and Containers From Development to Deployment
 
SD Times - Docker v2
SD Times - Docker v2SD Times - Docker v2
SD Times - Docker v2
 
SRV308 Deep Dive on Amazon Aurora
SRV308 Deep Dive on Amazon AuroraSRV308 Deep Dive on Amazon Aurora
SRV308 Deep Dive on Amazon Aurora
 
Architecting SAP on Amazon Web Services - SVC216 - Chicago AWS Summit
Architecting SAP on Amazon Web Services - SVC216 - Chicago AWS SummitArchitecting SAP on Amazon Web Services - SVC216 - Chicago AWS Summit
Architecting SAP on Amazon Web Services - SVC216 - Chicago AWS Summit
 
STG330_Case Study How Experian Leverages Amazon EC2, EBS, and S3 with Clouder...
STG330_Case Study How Experian Leverages Amazon EC2, EBS, and S3 with Clouder...STG330_Case Study How Experian Leverages Amazon EC2, EBS, and S3 with Clouder...
STG330_Case Study How Experian Leverages Amazon EC2, EBS, and S3 with Clouder...
 

More from Amazon Web Services

Come costruire servizi di Forecasting sfruttando algoritmi di ML e deep learn...
Come costruire servizi di Forecasting sfruttando algoritmi di ML e deep learn...Come costruire servizi di Forecasting sfruttando algoritmi di ML e deep learn...
Come costruire servizi di Forecasting sfruttando algoritmi di ML e deep learn...
Amazon Web Services
 
Big Data per le Startup: come creare applicazioni Big Data in modalità Server...
Big Data per le Startup: come creare applicazioni Big Data in modalità Server...Big Data per le Startup: come creare applicazioni Big Data in modalità Server...
Big Data per le Startup: come creare applicazioni Big Data in modalità Server...
Amazon Web Services
 
Esegui pod serverless con Amazon EKS e AWS Fargate
Esegui pod serverless con Amazon EKS e AWS FargateEsegui pod serverless con Amazon EKS e AWS Fargate
Esegui pod serverless con Amazon EKS e AWS Fargate
Amazon Web Services
 
Costruire Applicazioni Moderne con AWS
Costruire Applicazioni Moderne con AWSCostruire Applicazioni Moderne con AWS
Costruire Applicazioni Moderne con AWS
Amazon Web Services
 
Come spendere fino al 90% in meno con i container e le istanze spot
Come spendere fino al 90% in meno con i container e le istanze spot Come spendere fino al 90% in meno con i container e le istanze spot
Come spendere fino al 90% in meno con i container e le istanze spot
Amazon Web Services
 
Open banking as a service
Open banking as a serviceOpen banking as a service
Open banking as a service
Amazon Web Services
 
Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...
Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...
Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...
Amazon Web Services
 
OpsWorks Configuration Management: automatizza la gestione e i deployment del...
OpsWorks Configuration Management: automatizza la gestione e i deployment del...OpsWorks Configuration Management: automatizza la gestione e i deployment del...
OpsWorks Configuration Management: automatizza la gestione e i deployment del...
Amazon Web Services
 
Microsoft Active Directory su AWS per supportare i tuoi Windows Workloads
Microsoft Active Directory su AWS per supportare i tuoi Windows WorkloadsMicrosoft Active Directory su AWS per supportare i tuoi Windows Workloads
Microsoft Active Directory su AWS per supportare i tuoi Windows Workloads
Amazon Web Services
 
Computer Vision con AWS
Computer Vision con AWSComputer Vision con AWS
Computer Vision con AWS
Amazon Web Services
 
Database Oracle e VMware Cloud on AWS i miti da sfatare
Database Oracle e VMware Cloud on AWS i miti da sfatareDatabase Oracle e VMware Cloud on AWS i miti da sfatare
Database Oracle e VMware Cloud on AWS i miti da sfatare
Amazon Web Services
 
Crea la tua prima serverless ledger-based app con QLDB e NodeJS
Crea la tua prima serverless ledger-based app con QLDB e NodeJSCrea la tua prima serverless ledger-based app con QLDB e NodeJS
Crea la tua prima serverless ledger-based app con QLDB e NodeJS
Amazon Web Services
 
API moderne real-time per applicazioni mobili e web
API moderne real-time per applicazioni mobili e webAPI moderne real-time per applicazioni mobili e web
API moderne real-time per applicazioni mobili e web
Amazon Web Services
 
Database Oracle e VMware Cloud™ on AWS: i miti da sfatare
Database Oracle e VMware Cloud™ on AWS: i miti da sfatareDatabase Oracle e VMware Cloud™ on AWS: i miti da sfatare
Database Oracle e VMware Cloud™ on AWS: i miti da sfatare
Amazon Web Services
 
Tools for building your MVP on AWS
Tools for building your MVP on AWSTools for building your MVP on AWS
Tools for building your MVP on AWS
Amazon Web Services
 
How to Build a Winning Pitch Deck
How to Build a Winning Pitch DeckHow to Build a Winning Pitch Deck
How to Build a Winning Pitch Deck
Amazon Web Services
 
Building a web application without servers
Building a web application without serversBuilding a web application without servers
Building a web application without servers
Amazon Web Services
 
Fundraising Essentials
Fundraising EssentialsFundraising Essentials
Fundraising Essentials
Amazon Web Services
 
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...AWS_HK_StartupDay_Building Interactive websites while automating for efficien...
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...
Amazon Web Services
 
Introduzione a Amazon Elastic Container Service
Introduzione a Amazon Elastic Container ServiceIntroduzione a Amazon Elastic Container Service
Introduzione a Amazon Elastic Container Service
Amazon Web Services
 

More from Amazon Web Services (20)

Come costruire servizi di Forecasting sfruttando algoritmi di ML e deep learn...
Come costruire servizi di Forecasting sfruttando algoritmi di ML e deep learn...Come costruire servizi di Forecasting sfruttando algoritmi di ML e deep learn...
Come costruire servizi di Forecasting sfruttando algoritmi di ML e deep learn...
 
Big Data per le Startup: come creare applicazioni Big Data in modalità Server...
Big Data per le Startup: come creare applicazioni Big Data in modalità Server...Big Data per le Startup: come creare applicazioni Big Data in modalità Server...
Big Data per le Startup: come creare applicazioni Big Data in modalità Server...
 
Esegui pod serverless con Amazon EKS e AWS Fargate
Esegui pod serverless con Amazon EKS e AWS FargateEsegui pod serverless con Amazon EKS e AWS Fargate
Esegui pod serverless con Amazon EKS e AWS Fargate
 
Costruire Applicazioni Moderne con AWS
Costruire Applicazioni Moderne con AWSCostruire Applicazioni Moderne con AWS
Costruire Applicazioni Moderne con AWS
 
Come spendere fino al 90% in meno con i container e le istanze spot
Come spendere fino al 90% in meno con i container e le istanze spot Come spendere fino al 90% in meno con i container e le istanze spot
Come spendere fino al 90% in meno con i container e le istanze spot
 
Open banking as a service
Open banking as a serviceOpen banking as a service
Open banking as a service
 
Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...
Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...
Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...
 
OpsWorks Configuration Management: automatizza la gestione e i deployment del...
OpsWorks Configuration Management: automatizza la gestione e i deployment del...OpsWorks Configuration Management: automatizza la gestione e i deployment del...
OpsWorks Configuration Management: automatizza la gestione e i deployment del...
 
Microsoft Active Directory su AWS per supportare i tuoi Windows Workloads
Microsoft Active Directory su AWS per supportare i tuoi Windows WorkloadsMicrosoft Active Directory su AWS per supportare i tuoi Windows Workloads
Microsoft Active Directory su AWS per supportare i tuoi Windows Workloads
 
Computer Vision con AWS
Computer Vision con AWSComputer Vision con AWS
Computer Vision con AWS
 
Database Oracle e VMware Cloud on AWS i miti da sfatare
Database Oracle e VMware Cloud on AWS i miti da sfatareDatabase Oracle e VMware Cloud on AWS i miti da sfatare
Database Oracle e VMware Cloud on AWS i miti da sfatare
 
Crea la tua prima serverless ledger-based app con QLDB e NodeJS
Crea la tua prima serverless ledger-based app con QLDB e NodeJSCrea la tua prima serverless ledger-based app con QLDB e NodeJS
Crea la tua prima serverless ledger-based app con QLDB e NodeJS
 
API moderne real-time per applicazioni mobili e web
API moderne real-time per applicazioni mobili e webAPI moderne real-time per applicazioni mobili e web
API moderne real-time per applicazioni mobili e web
 
Database Oracle e VMware Cloud™ on AWS: i miti da sfatare
Database Oracle e VMware Cloud™ on AWS: i miti da sfatareDatabase Oracle e VMware Cloud™ on AWS: i miti da sfatare
Database Oracle e VMware Cloud™ on AWS: i miti da sfatare
 
Tools for building your MVP on AWS
Tools for building your MVP on AWSTools for building your MVP on AWS
Tools for building your MVP on AWS
 
How to Build a Winning Pitch Deck
How to Build a Winning Pitch DeckHow to Build a Winning Pitch Deck
How to Build a Winning Pitch Deck
 
Building a web application without servers
Building a web application without serversBuilding a web application without servers
Building a web application without servers
 
Fundraising Essentials
Fundraising EssentialsFundraising Essentials
Fundraising Essentials
 
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...AWS_HK_StartupDay_Building Interactive websites while automating for efficien...
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...
 
Introduzione a Amazon Elastic Container Service
Introduzione a Amazon Elastic Container ServiceIntroduzione a Amazon Elastic Container Service
Introduzione a Amazon Elastic Container Service
 

DAT305_Amazon ElastiCache Deep Dive

  • 1. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. AWS re:INVENT Amazon ElastiCache Deep Dive: Best Practices and Usage Patterns M i c h a e l L a b i b , N o S Q L S p e c i a l i s t S A , A W S
  • 2. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. What to expect from this session • Amazon ElastiCache overview • Scaling your cluster with online re-sharding • Amazon ElastiCache security and encryption • Amazon ElastiCache usage patterns • Best practices
  • 3. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon ElastiCache µs is the new ms
  • 4. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. In-memory key-value store supporting • Redis 3.2.10 • Memcached 1.4.34 High-performance Fully managed; zero admin Highly available and reliable Hardened by Amazon Amazon ElastiCache
  • 5. Request rate High Low Latency Low High Structure Low High Data volume Low High Amazon RDS Amazon S3 Amazon Glacier Amazon CloudSearch and Amazon Elasticsearch Service Amazon DynamoDB Amazon ElastiCache and Amazon DynamoDB Accelerator (DAX) HDFS
  • 6. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Powerful ~200 commands + Lua scripting In-memory data structure server Utility data structures Strings, lists, hashes, sets, sorted sets, bitmaps, and HyperLogLogs Simple Atomic operations supports transactions Ridiculously fast! <1 ms latency for most commands Highly available replication Persistence Open source Redis overview
  • 7. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. But wait, there’s more! Run Lua scripts Geospatial queries Pub/sub
  • 8. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. SMEMBERS features REDIS:6379> Amazon ElastiCache 1) “Easy to deploy & monitor” AWS Config Amazon CloudWatch AWS CloudTrail AWS CloudFormation AWS Management Console AWS CLI and SDKs alarm REDIS:6379> hget feature:details “deploy-monitor” Amazon SNS Email Notification AWS Lambda
  • 9. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. SMEMBERS features REDIS:6379> REDIS:6379> hget feature:details “enhancements” 2) “Enhanced Redis Engine” Optimized Swap Memory •Mitigate the risk of increased swap usage during syncs and snapshots Dynamic write throttling •Improved output buffer management when the node’s memory is close to being exhausted Smoother failovers •Clusters recover faster as replicas avoid flushing their data to do a full re-sync with the primary Amazon ElastiCache
  • 10. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. SMEMBERS ec-team:open-source:contributorsREDIS:6379> https://raw.githubusercontent.com/antirez/redis/2.8/00-RELEASENOTES (from https://github.com/antirez/redis/issues/1814) 1) “Kevin McGehee” 2) “Qu Chen” 3) “Rajib Dugar” hgetall ec-team:open-source:contributionsREDIS:6379> 1) PSYNC2 (Redis 4.0) https://raw.githubusercontent.com/antirez/redis/4.0/00-RELEASENOTES 3) BGSAVE (Redis 3.2) https://raw.githubusercontent.com/antirez/redis/3.2/00-RELEASENOTES 5) MIGRATE (Redis 3.0) 7) MASTER TIMEOUT (Redis 2.8) https://raw.githubusercontent.com/antirez/redis/3.0/00-RELEASENOTES https://raw.githubusercontent.com/antirez/redis/2.8/00-RELEASENOTES 9) INCREASE 2Billion+ KEYS in a DATASET (Redis 2.8) 2) 4) 6) 8) 10) Amazon ElastiCache 11) also: 4114, 4250, 3926, 3899
  • 11. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Slot 0-5461 Cluster Mode Disabled Keyspace Slot 10923-16383 I Primary 0–5 Replicas Cluster Mode Enabled Primary Endpoint 1–15 Primaries/Shards Slot 0 Slot 5462-10922 Slot 16383 Keyspace 0–5 Replicas Configuration Endpoint Slot 1 … Vertically Scaled Horizontally Scaled Max Storage 407 GiB Max Storage 6+ TiB Redis topologies
  • 12. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Feature Enabled Disabled Failover 15–30 sec (Non-DNS) ~1.5 min (DNS-based) Failover risk • Writes affected—partial dataset (less risk with more partitions) • Reads available • Writes affected on entire dataset • Reads available Performance Scales with cluster size (90 nodes—15 primaries + 0–5 replicas per shard) 6 nodes (1 primary + 0–5 replicas) Max connections • Primaries (65,000 x 15 = 975,000) • Replicas (65,000 x 75 = 4,875,000) • Primary: 65,000 • Replicas: (65,000 x 5 = 325,000) Storage 6+ TiB 407 GB Cost Example: Assume workload needs 175 GB Smaller nodes but more $$ 9 x cache.r3.xlarge ($0.455hr) = $4.095 hr 255.6 GB Larger nodes less $ 1 X cache.r3.8xlarge = $3.640, 237 GB Redis cluster-mode enabled vs. disabled
  • 13. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Closer look at cluster-mode enabled
  • 14. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. S5 S1 S2 S4 S3 Client  16384 hash slots per cluster  Slot for a key is CRC16(key) mod 16384  Slots are distributed across the cluster into shards  Developers must use a Redis cluster aware client  Clients are redirected to the correct shard  Smart clients store a map Shard S1 = slots 0–3276 Shard S2 = slots 3277–6553 Shard S3 = slots 6554–9829 Shard S4 = slots 9830–13106 Shard S5 = slots 13107–16383 Redis cluster: automatic client-side sharding
  • 15. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Availability Zone A slots 0–5454 slots 5455–10909 Redis Cluster Redis cluster—architecture slots 10910–16363 Availability Zone B Availability Zone C slots 5455–10909 slots 5455–10909slots 0–5454 slots 0–5454 slots 10910–16363 slots 10910–16363 Redis cluster—multi-AZ A cluster consists of 1 to 15 shards Example: 3-shard cluster, 2 read replicas
  • 16. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Availability Zone A slots 0–5454 Redis Cluster Redis cluster—architecture slots 10910–16363 Availability Zone B Availability Zone C slots 5455–10909 slots 5455–10909slots 0–5454 slots 0–5454 slots 10910–16363 Shard ReplicaReplicaPrimary Each shard has a primary node and up to five replica nodes slots 5455–10909 slots 10910–16363
  • 17. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Availability Zone A slots 0–5454 slots 5455–10909 Redis Cluster Redis cluster—architecture slots 10910–16363 Availability Zone B Availability Zone C slots 5455–10909 slots 5455–10909 Shard ReplicaReplica Primary Each shard has a primary node and up to five replica nodes slots 0–5454 slots 0–5454 slots 10910–16363 slots 10910–16363
  • 18. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Availability Zone A slots 0–5454 Redis Cluster Redis cluster—architecture slots 10910–16363 Availability Zone B Availability Zone C slots 10910–16363 slots 10910–16363 Shard Replica PrimaryReplica Each shard has a primary node and up to five replica nodes slots 5455–10909 slots 0–5454 slots 5455–10909 slots 0–5454 slots 5455–10909
  • 19. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Availability Zone A slots 0–5454 slots 5455–10909 Redis Cluster slots 10910–16363 Availability Zone B Availability Zone C slots 5455–10909 slots 5455–10909slots 0–5454 slots 0–5454 slots 10910–16363 slots 10910–16363 Scenario 1: Single primary failure
  • 20. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Availability Zone A slots 0–5454 slots 5455–10909 Redis Cluster Scenario 1: Single primary failure slots 10910–16363 Availability Zone B Availability Zone C slots 5455–10909 slots 5455–10909slots 0–5454 slots 0–5454 slots 10910–16363 Mitigation: 1. Automatic failure detection and replica promotion (~15–30 s) 2. Repair failed node slots 10910–16363
  • 21. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Availability Zone A slots 0–5454 slots 5455–10909 Redis Cluster Scenario 2: Majority of primaries fail slots 10910–16363 Availability Zone B Availability Zone C slots 5455–10909 slots 5455–10909slots 0–5454 slots 0–5454 slots 10910–16363slots 10910–16363
  • 22. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Availability Zone A slots 0–5454 slots 5455–10909 Redis Cluster slots 10910–16363 Availability Zone B Availability Zone C slots 5455–10909 slots 5455–10909slots 0–5454 slots 0–5454 Mitigation: Redis enhancements on ElastiCache • Automatic failure detection and replica promotion • Repair failed nodes slots 10910–16363slots 10910–16363 Scenario 2: Majority of primaries fail
  • 23. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. aws elasticache create-snapshot --replication-group-id redisclusterID --snapshot-name snameStep 1 aws elasticache copy-snapshot --source-snapshot-name sname --target-snapshot-name sname --target-bucket s3ucketname Step 2 Step 3 aws elasticache create-replication-group --replication-group-id NewRedisClusterID … --snapshot-arns arn:aws:s3:::bucketname/redisbackup-0001.rdb, etc. Step 4 Once the new cluster is up, update your app with new Amazon ElastiCache endpoint, then terminate old cluster 3 Shards 5 Shards Downtime New writes not in snapshot rdb Pro tip: DR strategy—enable CRR on Amazon S3 bucket triggering AWS Lambda function to hydrate destination cluster Resizing via backup and restore
  • 24. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Zero-downtime Online Re-sharding
  • 25. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. 0-5461 Shard 1 Shard 2 Shard 3 5462--10922 10923-16383 aws elasticache modify-replication-group-shard-configuration --replication-group-id rep-group-id --apply-immediately --node-group-count 5 Simple API Scale In || Out Online Re-Sharding—zero downtime
  • 26. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. 0-5461 reads/writes Shard 1 Shard 2 Shard 3 Shard 4 Shard 5 5462--10922 10923-163830-2909, 5095-5461 5462-5783, 6876-9830 10923-14199 2910-5094, 9831--10922 No application interruption Uniform slot distribution across shards 5784-6875, 14200-16383 Online Re-Sharding—zero downtime: Scale Out
  • 27. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. 0-5461 reads/writes Shard 1 Shard 2 Shard 3 Shard 4 Shard 5 5462--10922 10923-16383 Uniform slot distribution across shards No Application Interruption Online Re-Sharding—zero downtime: Scale In
  • 28. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. AWS Lambda 3 Shards … var params = { ApplyImmediately: true, NodeGroupCount: 5, ReplicationGroupId: ‘rep-group-id’, … } elasticache.modifyReplicationGroupShardConfiguration(params, function(err, data) { if (err) console.log(err, err.stack); else console.log(data); }); … 5 Shards MEMORY HIGH! Amazon CloudWatch Cluster Resized AWS SNS Online Re-Sharding—CW alarm triggered
  • 29. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. reads/ writes reads AZ1 AZ2 reads search reads search clients c a c h e c l u s t e r r e l a t i o n a l d a t a Healthy
  • 30. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. reads/ writes reads AZ1 AZ2 reads search reads search clients c a c h e c l u s t e r r e l a t i o n a l d a t a Heavy pressure
  • 31. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. reads/ writes reads AZ1 AZ2 reads search reads search c a c h e c l u s t e r clients r e l a t i o n a l d a t a Healthy— auto scaled out
  • 32. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon ElastiCache security
  • 33. ElastiCache Redis reference architecture Availability Zone B Availability Zone CAvailability Zone A REDIS:6379> hget feature:details “ref-arch”
  • 34. ElastiCache Redis Reference Architecture Availability Zone B Availability Zone CAvailability Zone A Private SubnetPrivate Subnet Private Subnet REDIS:6379> hget feature:details “ref-arch”
  • 35. ElastiCache Redis Reference Architecture Availability Zone B Availability Zone CAvailability Zone A Private SubnetPrivate Subnet Private Subnet REDIS:6379> hget feature:details “ref-arch” security group security group security group
  • 36. ElastiCache Redis Reference Architecture Availability Zone B Availability Zone CAvailability Zone A Private SubnetPrivate Subnet Private Subnet REDIS:6379> hget feature:details “ref-arch” security group security group security group ElastiCache Redis Cluster Amazon S3 bucket REDIS RDB snapshot Encryption at REST
  • 37. ElastiCache Redis Reference Architecture Availability Zone B Availability Zone CAvailability Zone A Private SubnetPrivate Subnet Private Subnet REDIS:6379> hget feature:details “ref-arch” security group security group security group ElastiCache Redis Cluster security group Public Subnet security group Public Subnet Public Subnet Amazon S3 bucket REDIS RDB snapshot security group Encryption In-Transit 3.2.6 Redis AUTH Encryption at REST
  • 38. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Encryption • In-Transit: encrypt all communications between clients and Redis server as well as between nodes • At-Rest: encrypt backups on disk and in Amazon S3 • Fully managed: setup via API or console, automatic issuance and renewal Compliance • HIPAA eligibility for ElastiCache for Redis • Included in AWS Business Associate Addendum • Redis 3.2.6 Amazon ElastiCache Encryption and Compliance
  • 39. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Common usage patterns
  • 40.
  • 41. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Session management Database caching APIs (HTTP responses) IOT Streaming data analytics (Filtering/aggregation) Pub/sub Social media (Sentiment analysis) Standalone database (Metadata store) Leaderboards Usage patterns
  • 42. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Caching Clients Amazon ElastiCache Redis Amazon DynamoDB Elastic Load Balancing Amazon EC2 Amazon RDS write-through reads/ writes DDB streams mysql.lambda_async reads/ writes Amazon S3 reads/writes Object data Unstructured data Relational data
  • 43. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Caching NoSQL Amazon EC2 reads/ writes reads MongoDB Cluster Cassandra Cluster  Smaller NoSQL DB clusters needed = lower costs  Faster data retrieval = better performance Elasticsearch Cluster Clients
  • 44. Amazon EC2 reads/ writes Amazon ElastiCache Redis reads MongoDB Cluster DBObject doc = collection.findOne(); Cache serialized DBObject in Redis (good) Cache rows in Redis hash (faster/more efficient) Cassandra Cluster Amazon ElastiCache Redis Amazon EC2 reads/ writes reads ResultSet rs = session.execute(stmt); Cache serialized ResultSet in Redis (good) Cache rows in Redis hash (faster/more efficient)  Smaller NoSQL DB clusters needed = lower costs  Faster data retrieval = better performance Caching NoSQL databases with Amazon ElastiCache
  • 45. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Kinesis Analytics Amazon Kinesis Streams Amazon Kinesis Streams Amazon ElastiCache (Redis) cleansed stream Streaming data enrichment/processing Datasources raw stream Subscribers AWS Lambda function 1 Continual data filtering/enrichment Real-time pub/sub AWS Lambda function 2
  • 46. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Big data architectures using Redis Amazon Kinesis DataSources AWS Lambda Apache Storm on EMR Spark Streaming on Amazon EMR Amazon Kinesis app Amazon EC2 AWS IoT Amazon ElastiCache Collect Store Process Amazon S3 Apache Kafka AWS Lambda Custom app Spark on Amazon EMR Analyze
  • 47. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Rules Engine Amazon ElastiCache Redis AWS Lambda Direct integration LambdaSNS SQS S3 KinesisDDB AWS IoT devices AWS IoT Sensor store IoT powered by ElastiCache
  • 48. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Mobile apps powered by ElastiCache Amazon API Gateway AWS Lambda Amazon ElastiCache Redis GEOADD GEORADIUS Search points of interest Update points of interest https://aws.amazon.com/blogs/database/amazon-elasticache-utilizing-redis-geospatial-capabilities/ Amazon DynamoDB DDB streams Amazon EC2
  • 49. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Ad tech powered by ElastiCache Clients Advertisers https://aws.amazon.com/caching/database-caching/ Ad network Ad slot Consumer Ad slot publishers Ad placement (websites/apps) Amazon ElastiCache Redis <40 ms Clickstream (shopping events) User visits page Publisher places ad slot for auction Ad network calls for bidsBidders respond with bids Winners bid ad displayed
  • 50. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Chat apps powered by ElastiCache https://aws.amazon.com/blogs/database/amazon-elasticache-utilizing-redis-geospatial-capabilities/ Clients Chat apps Application Load Balancer WebSockets Amazon ElastiCache Redis PubSub Serverpersistent connections Elastic Beanstalk SUBSCRIBE chat_channel:114 PUBLISH chat_channel:114 "Hello all" >> ["message", "chat_channel:114", "Hello all"] UNSUBSCRIBE chat_channel:114
  • 51. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. • Very popular for gaming apps that need uniqueness and ordering • Easy with Redis sorted sets ZADD "leaderboard" 1201 "Gollum” ZADD "leaderboard" 963 "Sauron" ZADD "leaderboard" 1092 "Bilbo" ZADD "leaderboard" 1383 "Frodo” ZREVRANGE "leaderboard" 0 -1 1) "Frodo" 2) "Gollum" 3) "Bilbo" 4) "Sauron” ZREVRANK "leaderboard" "Sauron" (integer) 3 Gaming—real-time leaderboards
  • 52. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Ex: throttling requests to an API uses Redis counters ELB Externally facing API Reference: http://redis.io/commands/INCR FUNCTION LIMIT_API_CALL(APIaccesskey) limit = HGET(APIaccesskey, “limit”) time = CURRENT_UNIX_TIME() keyname = APIaccesskey + ":” + time count = GET(keyname) IF current != NULL && count > limit THEN ERROR ”API request limit exceeded" ELSE MULTI INCR(keyname) EXPIRE(keyname,10) EXEC PERFORM_API_CALL() END Rate limiting
  • 53. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon ElastiCache: Best practices
  • 54. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Cluster sizing best practices • Storage—clusters should have adequate memory • Recommended: memory needed + 25% reserved memory (for Redis) + some room for growth (optional 10%) • Optimize using eviction policies and TTLs • Scale up or out before reaching max-memory using CloudWatch alarms • Use memory optimized nodes for cost effectiveness (R4 support) • Performance—performance should not be compromised • Benchmark operations using Redis Benchmark tool • For more READIOPS—add replicas • For more WRITEIOPS—add shards (scale out) • For more network IO—use network optimized instances and scale out • Use pipelining for bulk reads/writes • Consider Big(O) time complexity for data structure commands • Cluster isolation (apps sharing key space)—choose a strategy that works for your workload • Identify what kind of isolation is needed based on the workload and environment • Isolation: No Isolation $ | Isolation by Purpose $$ | Full Isolation $$$
  • 55. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Redis benchmark tool Open source utility to benchmark performance example: src/redis-benchmark -h r3-xlarge-perf.foio87.0001.use1.cache.amazonaws.com -p 6379 -n -150000 -d 100 Syntax: redis-benchmark -h <host> -p <port> -c 50 -n 1000 -d 500 –q -c <clients>—Specifies the number of parallel connections (default 50). -n <requests>—Specifies the number of requests (default 1000000). -d <size>—Specifies the data size of GET and SET values in bytes. -t <test1,test2>—Comma-separated list of tests to perform. -q—Quiet operation, displays only the result.
  • 56. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Redis max-memory policies Select a max-memory policy based on your workload needs • noeviction: return errors when the memory limit has been reached and the client is trying to execute commands that might result in more memory to be used • allkeys-lru: evict keys trying to remove the less recently used (LRU) keys first • volatile-lru: evict keys trying to remove the less recently used (LRU) keys first, but only among keys that have an expire set • allkeys-random: evict random keys to make space for the new data added • volatile-random: evict random keys to make space for the new data added, but only evict keys with an expire set • volatile-ttl: evict only keys with an expire set, and try to evict keys with a shorter time to live (TTL) first
  • 57. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Key ElastiCache CloudWatch metrics • CPUUtilization • Memcached—up to 90% ok • Redis—divide by cores (ex: 90% / 4 = 22.5%) • SwapUsage low • CacheMisses/CacheHits Ratio low/stable • Evictions near zero • Exception: Russian-doll caching • CurrConnections stable • Setup alarms with CloudWatch metrics
  • 58. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. ElastiCache modifiable parameters • Maxclients: 65000 (unchangeable) • Use connection pooling • timeout—closes a connection after it has been idle for a given interval • tcp-keepalive—detects dead peers given an interval • Databases: 16 (default) for non-clustered mode • Logical partition • Reserved-memory: 25% (default) • Recommended  50% of maxmemory to use before 2.8.22  25% after 2.8.22—ElastiCache • Maxmemory-policy: • The eviction policy for keys when maximum memory usage is reached • Possible values: volatile-lru, allkeys-lru, volatile-random, allkeys-random, volatile-ttl, noeviction
  • 59. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. • Understand the frequency of change of underlying data • Set appropriate TTLs on keys that match that frequency • Choose appropriate eviction policies that are aligned with application requirements • Isolate your cluster by purpose (for example, cache cluster, queue, standalone database, and so on) • Maintain cache freshness with write-throughs • Performance test and size your cluster appropriately • Monitor Cache HIT/MISS ratio and alarm on poor performance • Use failover API to test application resiliency Caching tips
  • 60. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Thank you!