azure redis cache - cache on steroids!

Post on 16-Jan-2017

113 Views

Category:

Technology

3 Downloads

Preview:

Click to see full reader

TRANSCRIPT

AZURE REDIS CACHE Cache on Steroids!

ABOUT ME

AGENDA• Redis Cache Introduction• Azure Redis• Demo - Sample Application• Data Types• Queue Pattern• Pub / Sub• Azure Scalability (Tiers)

REDIS DEFINITION

Redis is an open source, (BSD licensed), in-memory data structure store, used as database, cache and message broker. It supports data structures such as strings, hashes, lists, sets, sorted sets with range queries, bitmaps, hyperloglogs, and geospatial indexes with radius queries.

REDIS - REmote DIctionary Server

Redis.io

WHO USES REDIS?

COMMON REDIS USAGES• Show latest items in home page • Leaderboards • Counting Stuff - Page Hits • Session State , Output Cache• Unique Visitors • Caching

CREATE YOUR FIRST REDIS CACHE

REDIS - DATA TYPES• String - key value

• Lists - list of string, sorted by insertion order

• Hashes - map between string fields and string values

• Sets - unordered collection of strings

• Sorted Set - similar to sets but each entry has an associated “score”

SAMPLE APPLICATION -TWEETER• Tweets

• Timeline

• Accounts

• Account Statistics

• Followers

• Following

• Favorite Hashtagsby Marc Dugas

Features• Can store any kind of data (JPEG images, serialized JSON)• Maximum size 512MB

Operations• INCR, DECR, INCRBY, APPEND, EXPIRE

Uses• Counters (Hits), Rate Limiter (API)

key value

STRING DATA TYPE

key

9

numberoffollowers

tweetcount 843

HASH DATA TYPEFeatures• Map between string fields and string value• 4 billion fields per hash

Operations• HGET, HSET, HINCRBY

Uses• Statistics for Entity (ex: Number of Followers)

d a bc

LIST DATA TYPEFeatures• List of strings sorted by insertion order• Can add to head or tail• 4 billion elements per list• Very fast access to items from head/tail

Operations• LPUSH, RPUSH, LRANGE, LTRIM, LPOP, RPOP

Uses• Timeline

ae

c

bd

f

SET DATA TYPEFeatures• Unordered collection of strings, no repeating members• Add/Remove and test for existing extremely quick• 4 billion elements per set• Union and Intersection between sets

Operations• SADD, SREM, SUNION, SINTER

Uses• Common Followers

Features• Similar to Set → no repeating members• Each member is associated with a score that is used to order the set

Operations• ZADD, ZRANGE, ZRANK

Uses• Leaderboards

c

9

a

3

b

-1

member

score

SORTED SET DATA TYPE

background workers

waitinglist

processinglist

producer

QUEUE PATTERN

Approach• Leverage the Redis List Commands to create a distributed queuing mechanism

Operations• Enqueue LPUSH (add to waitinglist)• Dequeue RPOPLPUSH (RPOP from waitinglist, LPUSH on processinglist)• Post Processing LREM (remove from processinglist )

Features• Implementation of the Publish/Subscribe paradigm• Messages are “published” into channels (no knowledge of subscribers)• Subscribers express interest in channel and receive messages from that channel

Operations• PUBLISH , SUBSCRIBE, UNSUBSCRIBE

Uses• Real time applications, SignalR Scaleoutpublish

er

channel

subscribers

PUBLISH/SUBSCRIBE PATTERN

REDIS COMMANDS

• Console in Azure Portal• Redis command line tools

redis.io/commands

METRICS

Tier Pricing Tier

Node(s) Size MBPS Request per second

SLA

Basic

C0 - C6 1 node

250MB - 53GB 5 - 2,000 600 - 150,000

Standard

2 nodes Primary/Secondary

Premium P1 - P4 1 - 1000 node(s) 6GB - 53GB 2,000 - 4,000 140,000 - 250,000

AZURE REDIS

Premium Tier• Faster hardware• Higher throughput, lower latencies• Persistence• Cluster

WHAT’S NEXT? Azure Redis Cache - azure.microsoft.com/en-us/services/cache Redis Cache - redis.io

Twitter: @fboucheros Blog:frankysnotes.com Blog (FR): cloudenfrancais.com

top related