Amazon Elasticache Deep Dive - March 2017 AWS Online Tech Talks
Amazon ElastiCache (Dan Zamansky) - AWS DB Day
-
Upload
amazon-web-services-korea -
Category
Technology
-
view
625 -
download
4
Transcript of Amazon ElastiCache (Dan Zamansky) - AWS DB Day
Amazon ElastiCacheAWS In-Memory Data Store
Dan Zamansky
Senior Product Manager
Time : 11:30 – 12:00
Amazon ElastiCache
AGENDA
• Why In-Memory?
• ElastiCache
• Understanding Key Features
• Redis - Common Use Cases
Why In-Memory?
Modern Applications Require Real-Time Performance
• We live in a connected world (IoT)• Phones, Tablets, Cars, Air Conditioners, Toasters
• Experiences are increasingly contextual
• Apps need to provide real-time responses
• Database performance is frequently the bottleneck
• Load is spikey and unpredictable
Businesses Need To Be Ready For Success!
What is ElastiCache?
Amazon RDS
Amazon DynamoDB Amazon Redshift
Amazon ElastiCache
Compute Storage
AWS Global Infrastructure
Database
Application Services
Deployment & Administration
Networking
AWS Database Services
High Performance In-Memory Key-
Value Store in the Cloud
In-Memory Key-Value Store
High-performance
Redis and Memcached
Fully managed; Zero admin
Hardened by AmazonAmazon
ElastiCache
Fully managed service = Automated Operations
Redis/Memcached Datastore hosted on Amazon EC2 Amazon ElastiCache
AmazonRDS
Request RateHigh Low
Cost/GBHigh Low
LatencyLow High
Data VolumeLow High
AmazonGlacier
AmazonCloudSearch
Struct
ure
Low
High
AmazonDynamoDB
AmazonElastiCache
Memcached
Slab allocator
In-memory key-value datastorevery popular as a caching solution
Supports strings, objects
Multi-threaded
Insanely fast!
Very established
No persistence
Patterns for sharding
Redis – the in-memory king
Powerful ~200 commands
In-memory key-value datastore
Supports data typesstrings, lists, hashes, sets, sorted sets, bitmaps & HyperLogLogs
Single-threaded
Atomic operationssupports transactionshas ACID properties
Ridiculously fast!<1ms latency for most commands
Read replicas
Persistencesnapshots or append-only log
Pub/sub functionality
Amazon ElastiCache
Redis Multi-AZ
Easy Monitoring via CloudWatch
Fully Managed
Enhanced Redis Engine
Easy to Deploy & Use
ElastiCache vs. Self-Managed Redis
No Cross-AZ Data Transfer Costs
Engineered For Cloud Scale
Amazon ElastiCache
Enhanced Redis Engine – Hardened by Amazon
RDB Without Fork
• Mitigate the risk of increased swap
usage during syncs and snapshots.
Dynamic write throttling
• To improve output buffer
management when the node’s
memory is close to being exhausted
Smoother failovers
• Clusters recover faster as replicas will
avoid flushing their data to do a full
re-sync with the primary.
Mitigating Swap During Redis Fork
Prim
ary
Availability Zone A Availability Zone B
Replic
a
Replic
a
writesUse Primary Endpoint
reads
Use Read Replicas
Auto-Failover
Chooses replica with lowest replication lag
DNS endpoint is same
ElastiCache for Redis Multi-AZ
ElastiCache for Redis
ElastiCache for Redis
ElastiCache for Redis
Automatic Failover to a read replica in case of primary node failure
ElastiCacheAutomatessnapshots for persistence
ElastiCache with Redis Multi-AZ
Region
Availability Zone A Availability Zone B
Auto Scaling group
ElastiCache cluster
ElastiCache with Redis Multi-AZ
Region
Availability Zone A Availability Zone B
Auto Scaling group
ElastiCache cluster
ElastiCache with Redis Multi-AZ
Region
Availability Zone A Availability Zone B
Auto Scaling group
ElastiCache cluster
ElastiCache with Redis Multi-AZ
Region
Availability Zone A Availability Zone B
Auto Scaling group
ElastiCache cluster
Mitigating Replica Flushing – Enhanced Engine
Master Replicas
Alarms
Monitoring with CloudWatch
• Easily Accessible via the ElastiCache console
• Track health of your nodes
• Set alarms to act when need to address running into limitations
What apps can ElastiCache power?
We Run The Most Demanding Real-Time WorkloadsThousands of Customers Implementing Large Scale Caching, Leaderboards,
Session Management, Messaging, Queuing and more
Gaming AdTech Media Mobile Other
Let’s Talk Redis. Key Use Cases
Use Case #1 - Caching
Elastic LoadBalancing
EC2 App Instances
RDS MySQL DB Instance
ElastiCache
Database Writes
App Reads
ClientsCacheUpdates
Database Reads
Amazon ElastiCache
Eliminate database hotspots
Predictable Performance
Cut Load on Backend
Increase Read Throughput
Reduce App Latency
Caching Will Make Your Database More Efficient
Reduce Database Cost
Adding Caching to Your Application is Easy
Common Caching Technique #1 – Lazy Caching:
IGA Works Uses ElastiCache to Power Real-Time App Monetization
By using RDS we saved on operations
cost for our relational databases. Using
ElastiCache we could boost the read
performance of RDS and offload the
massive request rate
Jeongsang BaekVP Engineering, IGA Works
”
“• IGA Works is Korea’s leading mobile business platform
• Adpopcorn is an ad monetization platform for mobile applications
that supports 130 million devices
• Storing Ad Inventory in ElastiCache in front of RDS guaranteed real-
time ad bidding and serving, while RDS provides the durable
database layer
Expedia’s Real-time Analytics Application Uses Amazon ElastiCache
Expedia is a leader in the $1 trillion travel industry, with an extensive portfolio that includes some of the world’s most trusted travel brands.
With ElastiCache Redis as caching
layer, the write throughput on
DynamoDB has been set to 3500,
down from 35000, reducing the cost
by 6x.
Kuldeep ChowhanEngineering Manager, Expedia
”
“ • Expedia’s real-time analytics application collects data for its “test &
learn” experiments on Expedia sites.
• The analytics application processes ~200 million messages daily.
• Re:invent talk: https://www.youtube.com/watch?v=ie4dWGT76LM
Not if I destroy it first!
It’s mine!
• Very popular for gaming apps
• Need uniqueness + 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
Use Case 2 - Real-time Leaderboard
TV Globo (Media)
• Rede Globo is the second largest TV network in the
world.
• TV Globo used ElastiCache Redis for second screen
application during the World Cup in Brazil in 2014.
• ElastiCache was used for caching and leaderboards.
• Massive spikes in usage during games and peak
events.
Use Case 3 - Chat and Messaging
• PUBLISH and SUBSCRIBE Redis commands
• Game or Mobile chat, real-time comment streams
• Server intercommunication
SUBSCRIBE chat_channel:114PUBLISH chat_channel:114 "Hello all">> ["message", "chat_channel:114", "Hello all"]UNSUBSCRIBE chat_channel:114
• Popular for recommendation engines and message board ranking
• Redis counters – increment likes/dislikes
• Redis hashes – list of everyone’s ratings
• Process with algorithm like Slope One or Jaccardian similarity
• Ruby example - https://github.com/davidcelis/recommendable
Use Case 4 – Ratings
INCR item:38927:likesHSET item:38927:ratings "Susan" 1
INCR item:38927:dislikesHSET item:38927:ratings "Tommy" -1
• Ex: Throttling requests to an API
• Leverages Redis Counters
ELB
Externally Facing A
PI
Reference: http://redis.io/commands/INCR
FUNCTION LIMIT_API_CALL(APIaccesskey)limit = HGET(APIaccesskey, “limit”)time = CURRENT_UNIX_TIME()keyname = APIaccesskey + ":” + timecount = GET(keyname)IF current != NULL && count > limit THEN
ERROR ”API request limit exceeded"ELSE
MULTIINCR(keyname)EXPIRE(keyname,10)
EXECPERFORM_API_CALL()
END
Use Case 5 - Rate Limiting
• Redis is a powerful in-memory data structure server that allows you to easily build high performance apps
• ElastiCache provides the hardened, secure, highly-available, and performant platform to run in-memory data stores in the cloud
Recap
Thank You