28
The Story About Cache [email protected]

The story about cache

Embed Size (px)

DESCRIPTION

 

Citation preview

Page 1: The story about cache

The Story About Cache

[email protected]

Page 2: The story about cache

Use Case: Login

Page 3: The story about cache

Use Case: Login

Common Case

Page 4: The story about cache

Use Case: Login

Common Case Read From DB

Select * from Users where id=‘charsyam’;

Page 5: The story about cache

Use Case: Login

May be it’s genenally fast

Page 6: The story about cache

Use Case: Login

But it’s Slow In Many Read/Write

Page 7: The story about cache

Use Case: Login

Advanced Case Read From Cache

Get charsyam

Page 8: The story about cache

Use Case: Login

it’s always fast

Page 9: The story about cache

Use Case: Login

136 vs 1613 seconds

Memcache VS Mysql

Page 10: The story about cache

Use Case: Login

250 million User ID Request 10 million

Page 11: The story about cache

Where We Can Use Cache?

Just Check User exists? Mail Receive, Tweet Mention

Get User’s Profile Get User’s Timeline

Page 12: The story about cache

Caches

Memcache

Redis

Page 13: The story about cache

Memcache

Atomic Operation

Page 14: The story about cache

Memcache

Atomic Operation

Key:Value

Page 15: The story about cache

Memcache

Atomic Operation

Key:Value Single Thread

Page 16: The story about cache

Memcache

Over 100,000 TPS Processing

Page 17: The story about cache

Redis

Key:Value

Page 18: The story about cache

Redis

Key:Value

Collection

List Sorted Set

Page 19: The story about cache

Cache Layer

Cache

DBMS

Storage Layer

Application Server

READ

WRITE

WRITE UPDATE

Page 20: The story about cache

Cache Layer Like Twitter

K: UserID, V: Y/N

K: UserID_TIMELINE, V: Tweet IDs

K: UserID_TWEETID, V: Tweet Contents

Check User exists

Check tweet list

Check Content

1st Level Cache

2nd Level Cache

3rd Level Cache

Page 21: The story about cache

BUTs

Sometimes Cache is slower than DB

Page 22: The story about cache

Why?

DBMS Also Uses Cache If Cache is hit. It’s faster than …

Page 23: The story about cache

DBMS

DBMS

Storage Layer

Application Server

READ

WRITE

Cache

Page 24: The story about cache

Environment

Small Data Sets Read Just 0.2~03mili

Page 25: The story about cache

Comparision

DB’s Cache: 0.2mili memCache: 0.4mili

If you check cache, you spend more time

Page 26: The story about cache

BUTs BUTs

Cache helps to reduce DBMS’s Loads

And It reduces Performance Deviation

Page 27: The story about cache

Use Cache!

Page 28: The story about cache

Thank you!