Mathilde Lemee
Advanced Concept of Caching
@MathildeLemee - Aetys
MILAN november 28th/29th 2014
HIT#codemotion @MathildeLemee
MISS
#codemotion @MathildeLemee
TTITTL
#codemotion @MathildeLemee
Tom wants to improve data
access #codemotion @MathildeLemee
CACHE ASIDE
Database
Application
Cache
DAO
HIT !Get A MISS !Get B
Read B
PUT !Put B HIT !Get B
#codemotion @MathildeLemee
Tom wants that the cache always have
updated datas.
#codemotion @MathildeLemee
System of
Record#codemotion @MathildeLemee
Cache as a s-o-r : Read through
Database
Application
Ehcache
Persistence layer
Get A
HIT !
#codemotion @MathildeLemee
Cache as a s-o-r : Read through
Database
Application
Ehcache
Persistence layer
Get AMISS!
#codemotion @MathildeLemee
Cache as a s-o-r : Write through
Database
Application
Ehcache
Persistence layer
PUT !
#codemotion @MathildeLemee
Tom works on a e-commerce website and want to have the faster data access.
#codemotion @MathildeLemee
Cache as a s-o-r : Write Behind
Database
Application
Ehcache
Persistence layer
PUT !Put A
Write-behind thread
APUT !Put B
BPUT !Put C
CPUT !Put D
D
Get A B C D
Write A B C D
#codemotion @MathildeLemee
AccessTime
#codemotion @MathildeLemee
Write Through Response times
#codemotion @MathildeLemee
Write Behind Response Times
#codemotion @MathildeLemee
Database
#codemotion @MathildeLemee
Write Through – Database load
#codemotion @MathildeLemee
Write Behind – Database load
#codemotion @MathildeLemee
Tom doesn't control the
datas#codemotion @MathildeLemee
REFRESH AHEAD
#codemotion @MathildeLemee
TTLTTR0
#codemotion @MathildeLemee
Paul work in a bank where at a fixed time datas
are updated#codemotion @MathildeLemee
SCHEDULEDREFRESH
AHEAD#codemotion @MathildeLemee
Choose#codemotion @MathildeLemee
CACHE ASIDE VS
READ/WRITE THROUGH
#codemotion @MathildeLemee
Refresh Ahead/Scheduled
Refresh VS
The world#codemotion @MathildeLemee
Refresh AheadVS
Scheduled Refresh Ahead
#codemotion @MathildeLemee
Write Behind VS
Write Through#codemotion @MathildeLemee
KNOW YOUR
DATAS#codemotion @MathildeLemee
CACHE
#codemotion @MathildeLemee
CACHE#codemotion @MathildeLemee
CACHE
#codemotion @MathildeLemee
Wikipedia
La scalabilité est la capacité qu’a
l’architecture pour
évoluer en cas de montée en
charge si nécessaire.
#codemotion @MathildeLemee
#codemotion @MathildeLemee
#codemotion @MathildeLemee
La scalabilité d’une
application est égale à la
scalabilité de son composant
le moins scalable.
#codemotion @MathildeLemee
#codemotion @MathildeLemee
DISTRIBUTION#codemotion @MathildeLemee
#codemotion @MathildeLemee
#codemotion @MathildeLemee
#codemotion @MathildeLemee
ET SI …#codemotion @MathildeLemee
#codemotion @MathildeLemee
#codemotion @MathildeLemee
5#codemotion @MathildeLemee
#codemotion @MathildeLemee
#codemotion @MathildeLemee
ET SI …#codemotion @MathildeLemee
#codemotion @MathildeLemee
#codemotion @MathildeLemee
#codemotion @MathildeLemee
#codemotion @MathildeLemee
#codemotion @MathildeLemee
#codemotion @MathildeLemee
#codemotion @MathildeLemee
#codemotion @MathildeLemee
ET SI …#codemotion @MathildeLemee
• Julie / 32 ans / 2 enfants / Paris• Paul / 27 ans / 4 enfants / Marseille• Thomas / 40 ans / 1 enfant / Paris
– Déménagement de Thomas sur Marseille
Qui habite sur Paris ?
Consistence
#codemotion @MathildeLemee
LOCAL QUORUM
ONE
TWO
THREE
QUORUM
ANYEACH QUORUM
#codemotion @MathildeLemee
CAP
• Consistency :• Availability : • Partionning
#codemotion @MathildeLemee
• Consistency + Available = RDBMS• Consistency + Partionning = BigTable / Hbase /
MongoDB / Redis• Available + Partionning =
Riak/Cassandra/CouchDB
#codemotion @MathildeLemee
IMDG
vs
Relational Database