DAT 353 Unlock the value of Redis in AWS

Mohan Varthakavi Kevin McGehee Sr. Manager, Software Development Principal Software Engineer Amazon ElastiCache Amazon ElastiCache

© 2019, , Inc. or its affiliates. All rights reserved. Who are you? Redis familiarity Agenda

• What is Redis & why does it matter? • Why would I use Amazon ElastiCache? • How do I use Redis? • Caching • Session store • Real-time streaming & analytics • Geospatial apps • Leaderboards • Q&A © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. Purpose-built

• Amazon Web Services builds purpose-built solutions to solve problems • Some use cases can leverage multiple solutions together Real-time apps need low latency and high throughput

Users: 1 million+ Data volume: 170 TB Locality: Global Performance: Microseconds Request rate: Millions Access: Mobile, IoT, and devices Scale: Up/down, in/out Economics: Pay as you go

Mobile Web E-commerce Gaming or apps apps location apps Developer access: Open APIs Redis: #1 key-value store, most-loved

* StackOverflow 2019 developer survey

* https://db-engines.com rankings for key-value store About Redis

Fast In-memory <1ms latency for key-value store most commands Powerful Open source ~200 commands, Lua scripting, Pub/Sub, transactions Easy to learn Various data structures Strings, lists, hashes, sets, sorted sets, Highly available streams, geospatial, bitmaps, streams Replication with failover and HyperLogLogs Scalable Backup/restore Scale horizontally or vertically Point-in-time snapshotting Self-managing Redis is challenging

Difficult Hard to make Difficult Expensive to manage highly available to scale

Manage server provisioning, Need to implement Online scaling can be error Invest in people, processes, software patching, setup, fast error detection prone, and replication hardware, and software configuration, and backups and remediation performance needs to be monitored Amazon ElastiCache for Redis Fully-managed, Redis compatible, in-memory data store in the cloud

Extreme performance Fully managed Easily scalable In-memory data store and cache for AWS manages all hardware and software Read scaling with replicas sub-millisecond response times setup, configuration, monitoring Write and memory scaling with sharding Online scaling

Reliable Secure and compliant Redis compatible Multi-AZ Amazon VPC Redis 5.0.5 Support Deep monitoring HIPAA, PCI, FedRAMP Redis clients compatible Automatic failover Encryption at-rest and in-transit Authentication © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. Use cases

Caching Real-time Gaming Geospatial Media analytics leaderboards streaming

Session Chat apps Message Machine store queues learning Caching

Challenge: Retrieving data from disk-based databases and applications is slow. Workarounds, such as specialized hardware, proprietary in-memory databases, and data reduction, are expensive, have high lock-in, don’t scale, and are difficult to manage Solution: Use Redis, an open source, in-memory data store and cache, to store frequently used data in memory for microsecond latency and high throughput Use cases: Database query caching, persistent session caching, and full web page caching Grab is Southeast Asia’s largest ride- hailing service with 45M downloads & 2.5M daily rides

Challenge: Average response time of the API layer is <40ms Solution: ElastiCache for Redis as a caching layer on RDS MySQL provides submillisecond latency, even in times of peak traffic of hundreds of thousands of cab requests per minute Session store

Challenge: Need low-latency and high-concurrency data stores to process fast-moving, ephemeral session data, such as authentication tokens, cookies, and session state Solution: Use Redis as an in- memory key-value store and cache with appropriate key expiration strategies to store and manage ephemeral session data for microsecond responses Apps: Web and mobile apps Session store details PHP example 1) Install , apache php redis client e.g., yum install php apache php-pecl-redis For situations where you need an 2) Configure "php.ini" external session store session.save_handler = rediscluster session.save_path = " seed[]=cluster-discovery-endpoint:6379& • Especially needed when using ASGs timeout=2& • Cache optimal for high-volume reads read_timeout=2& failover=error& persistent=1"

3) Restart httpd

4) Begin using session data Auto Scaling Instances Real-time streaming & analytics store

Challenge: Need a fast data store to process fast moving streaming data in real time Solution: Use Redis as an in- memory data store with versatile data structures, such as streams, lists, and sets, to ingest, process, and analyze real-time data with submillisecond latency Apps: Social media, ad targeting, personalization, IoT, and time- series data analytics Expedia is a leader in the $1 trillion travel industry with an extensive portfolio of brands

Challenge: Need in- memory data store & cache for real-time analytics application that processes ~200 million messages daily

Solution: ElastiCache for Redis as an in-memory data store and cache to speed up data ingest and analytics Geospatial apps

Challenge: Need low-latency and high-concurrency data stores to process fast moving location data in real time Solution: Use Redis as an in- memory data store with purpose- built data structures, such as sorted sets, encoding/decoding of location data, and APIs for location-specific indexing, searching, and sorting Apps: Ride-hailing, dating, social media, gaming, eCommerce Leaderboards

Challenge: Leaderboards need low-latency and high-concurrency data stores to process changing scores and update ranks in real time Solution: Use Redis as an in- memory data store with data structures, such as sorted sets and ranked lists, that ensure uniqueness of elements while maintaining lists sorted by scores with microsecond latency Apps: Gaming leaderboards, sales leaderboards Peloton is the leading in-home fitness company

Challenge: Leaderboard requires elasticity, low latency, and real-time processing to deliver customizable rider data for thousands of users riding together from the comfort of their homes Solution: ElastiCache for Redis as an in-memory data store provides scale & performance to process streaming data for on- demand, live leaderboard Redis aws.amazon.com/redis

ElastiCache for Redis Get started aws.amazon.com/elasticache/redis

Contact us aws.amazon.com/contact-us/ Questions

• How do I monitor my ElastiCache nodes? Learn databases with AWS Training and Certification Resources created by the experts at AWS to help you build and validate database skills

25+ free digital training courses cover topics and services related to databases, including: • Amazon Aurora • Amazon ElastiCache • Amazon Neptune • Amazon Redshift • Amazon DocumentDB • Amazon RDS • Amazon DynamoDB

Validate expertise with the new AWS Certified Database - Specialty beta exam

Visit aws.training

© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. Thank you!

Mohan Varthakavi Kevin McGehee [email protected] [email protected]

© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. Monitoring & tuning CacheMisses/CacheHits: Successful retrievals Reclaimed: Number of keys that have expired Evictions: Keys removed due to memory limits FreeableMemory: Amount of free memory on the host