SlideShare a Scribd company logo
1 of 50
C.R.E.A.M. get the memory (dollar dollar bill ya'll)
January 2024
Matthew D. Groves | DevRel Engineer
aka “Passionate Bravo”
Cache Rules Everything
Around Me
4
Latency Numbers Every Programmer Should Know
https://stackoverflow.com/questions/4087280/approximate-cost-to-access-various-caches-and-main-memory/4087315#4087315
5
The Need for Speed
https://www.slideshare.net/devonauerswald/walmart-pagespeedslide
6
Cache Rules Everything Around Me
Dollar dollar bill ya'll
Android apps iPhone apps
CPU cache
CDNs
Web browser
DNS
01/
02/
03/
04/
05/
06/
What is caching?
Use Cases
Reading from Cache
Writing into Cache
Cache Invalidation
Gotchas
Agenda
8
ho am I?
• Matthew D. Groves
• Microsoft MVP, author at Pluralsight, Manning, Apress
• DevRel Engineer at Couchbase
• https://twitter.com/mgroves
• https://www.linkedin.com/in/mgroves/
• C# Advent: https://csadvent.christmas/
9
1 hat is Caching?
10
Caching
Collection of duplicated data to serve future requests faster.
• First formally described by Maurice Wilkes in 1965
• "Slave Memories and Dynamic Storage Allocation" https://bit.ly/WilkesPaper
What is Caching?
Key Data
1 Proteck Ya Neck
2 C.R.E.A.M.
3 Brooklyn Zoo
4 Criminology
… …
Key Data
2 C.R.E.A.M.
4 Criminology
Records Cache
11
Powerpoint as a Cache
What is Caching?
Key Value
What year was Wu-Tang
Clan Formed?
1992
12
2 Caching Use Cases
13
Caching Use Cases
What is Caching used for?
14
Caching Use Case 1: Faster Database Access
• Databases can rely heavily on disk
• Reading the same data over again
could mean accessing the disk over
again
• Store frequently accessed data in a
cache, to reduce pressure on
database/disk
15
Caching Use Case 1: Faster Database Access
DATABASE
APP
LAN
CACHE
CACHE
CACHE
16
Caching Use Case 2: Faster Web Browsing
• Any given URL could result in
hundreds of files that are loaded
over HTTP
• A single JS file may be loaded by
every page on a site.
• Cache static assets (JS, images,
sound, icons, etc) on a user's laptop
to avoid loading them over the
network every time
17
Caching Use Case 2: Faster Web Browsing
CACHE
18
Caching Use Case 3: Efficient API Use
• API usage may involve an internet
call (with latency)
• API calls may cost per use, or may
be limited
• Storing results in cache may help
reduce latency AND reduce costs
19
Caching Use Case 3: Efficient API Use
API APP
LAN/WAN
CACHE
CACHE
CACHE
20
Caching Use Case 4: Microservice Availability
• Retrieving data from other
processes
• Latency is secondary concern
21
Caching Use Case 4: Microservice Availability
CACHE
22
Cache Rules Everything Around Me
Dollar dollar bill ya'll
Disconnected Availability
Slow
Repetition
Constrained
Costs
23
3 Reading From Cache
24
Using a Cache 101
Your Code
Key Value
A Protect Ya Neck
B C.R.E.A.M.
C Brooklyn Zoo
Cache
Key Value
A Protect Ya Neck
B C.R.E.A.M.
C Brooklyn Zoo
D Criminology
E Triumph
F Uzi
G Method Man
H Wu-Tang Clan Ain't . . .
. . . . . .
Database
1. Lookup "A"
2. Lookup "B"
3. Lookup "C"
HIT!
HIT!
MISS!
4. Lookup "C" again?
WALK OF SHAME
25
4 Writing Into Cache
26
What about writes?
• Data is duplicated, stored in cache and record
• The system is responsible for keeping the cache updated
• Commons methods:
• write-through
• write-around
• write-back
Stuff needs to get in the cache somehow
27
write-through
1. System gets a new/updated piece of data
2. Write to cache and record "at the same time"
a) Write to record
b) If that didn't succeed, the write failed.
c) Write to cache
d) If that didn't succeed, the write failed. Rollback (a).
e) If the system reaches this point, the write succeeded!
Why or why not use this?
28
write-around
1. System gets a new/updated piece of data
2. Write the data to the record ONLY
3. Invalidate the record in the cache
Why or why not use this?
29
write-back
1. System gets a new/updated piece of data
2. Write the data to the cache.
3. Update the record asynchronously (don't wait on it to finish)
4. If the cache write succeeded, then consider the write succeeded.
Why or why not use this?
30
Cache Writing Methods
Method Write performance Write integrity Best for…?
write-through
➖ ➕ High % reads
write-around
➖ ➕ High % read later
write-back
➕ ❔ Mixed reads / writes
31
Couchbase: A write-back implementation
A database with a built-in managed cache
https://docs.couchbase.com/server/current/learn/buckets-memory-and-storage/memory-and-storage.html
Other
Couchbase
Server
nodes
32
Couchbase and Writing to the Cache
await collection.InsertAsync("A", new { title = "Protect Ya Neck" });
await collection.InsertAsync("A", new { title = "Protect Ya Neck" }, options =>
{
options.Durability(DurabilityLevel.None);
// OR: options.Durability(DurabilityLevel.Majority);
// OR: options.Durability(DurabilityLevel.MajorityAndPersistToActive);
// OR: options.Durability(DurabilityLevel.PersistToMajority);
});
33
Durability (with 3 replicas)
None
Memory
Disk
Node 1 Node 2 Node 3
✔
⚠
⚠
⚠
⚠
⚠
Node 4
⚠
⚠
34
Durability (with 3 replicas)
Majority
Memory
Disk
Node 1 Node 2 Node 3
✔
⚠
⚠
⚠
✔
⚠
Node 4
✔
⚠
35
Durability (with 3 replicas)
MajorityAndPersistToActive
Memory
Disk
Node 1 Node 2 Node 3
✔
✔
⚠
⚠
✔
⚠
Node 4
✔
⚠
36
Durability (with 3 replicas)
PersistToMajority
Memory
Disk
Node 1 Node 2 Node 3
✔
✔
⚠
⚠
✔
✔
Node 4
✔
✔
37
Latency Numbers Every Programmer Should Know
https://stackoverflow.com/questions/4087280/approximate-cost-to-access-various-caches-and-main-memory/4087315#4087315
38
5 Cache Invalidation
39
Powerpoint as a Cache
Key Value
What year was Wu-Tang Clan
Formed?
1992
What was Wu-Tang's first album
called?
Enter the Wu-Tang
What year was Maurice Wilkes
born?
1913
What year did Maurice Wilkes
die?
2010
What is the most recent Wu-
Tang studio album?
Once Upon a Time in Shaolin
40
Cache Invalidation is Hard
There are only two hard things in Computer Science: cache
invalidation and naming things.
-- Phil Karlton
How to decide what to invalidate (what data to "evict"):
cache policy https://www.nndb.com/people/400/000031307/
41
Cache Policy 1: LRU (Least Recently Used)
Key How new?
A 0
B 1 3
C 2
D 4
Cache max size: 3
Order of reads: A, B, C, B, D
X
---------------------------------------------------------------------------------
42
Cache Policy 2: NRU (Not Recently Used)
Lower scores evicted (at random)
Key Referenced? Modified? Score
A 0 0 0
B 0 0 0
C 0 1 1
D 1 0 2
E 1 1 3
43
Cache Policy 3: None
Don't evict anything
44
More Cache Policies
• RR – random replacement
• FIFO and LIFO – treat a cache like a queue
• MRU – MOST recently used
• LFU – least frequently used
• Belady's algorithm – not possible to implement
• Machine learning
• https://en.wikipedia.org/wiki/Cache_replacement_policies
45
6 Gotchas
46
Gotcha 1: Cache Size
• Problem: too small or too big cache
• Symptom: High turnover and churn (many evictions) or long lifetimes (few
evictions)
• Solutions:
• Monitoring
• Size the cache
• "Value" vs "Full" eviction
47
Gotcha 2: "Close" Caching
• Problem: running the cache on the same machine as the application
• Symptom: redundancy, hot spots, inconsistency, availability
• Solutions:
• Use a distributed cache
• Running on its own machine(s) / cluster
• Couchbase, of course!
48
Gotcha 3: Bad Eviction Policy
• Problem: using the wrong eviction policy
• Symptom: lots of overhead, cache checking
• Solutions:
• Don't Write an Eviction Policy (or better yet don't write a Cache)
• Benchmarking: "hit ratio" and "latency"
• "Hit ratio" – how often a hit vs miss (e.g. "45% hit ratio")
• "Latency" – how long it takes from request to response (e.g. 10μs latency)
THANK YOU
50
References
• https://www.geeksforgeeks.org/not-recently-used-nru-page-replacement-algorithm/
• https://shahriar.svbtle.com/Understanding-writethrough-writearound-and-writeback-
caching-with-python
• https://en.wikipedia.org/wiki/Maurice_Wilkes
• https://safari.ethz.ch/digitaltechnik/spring2021/lib/exe/fetch.php?media=wilkes.pdf
• https://stackoverflow.com/a/4087315/40015
• https://www.techtarget.com/searchstorage/definition/cache
• https://en.wikipedia.org/wiki/Cache_replacement_policies
• https://docs.couchbase.com/dotnet-sdk/current/howtos/kv-operations.html#durability
• https://docs.couchbase.com/dotnet-sdk/current/concept-docs/durability-replication-failure-
considerations.html#durable-writes

More Related Content

Similar to CREAM - That Conference Austin - January 2024.pptx

Open source: Top issues in the top enterprise packages
Open source: Top issues in the top enterprise packagesOpen source: Top issues in the top enterprise packages
Open source: Top issues in the top enterprise packagesRogue Wave Software
 
Developing High Performance and Scalable ColdFusion Application Using Terraco...
Developing High Performance and Scalable ColdFusion Application Using Terraco...Developing High Performance and Scalable ColdFusion Application Using Terraco...
Developing High Performance and Scalable ColdFusion Application Using Terraco...ColdFusionConference
 
Developing High Performance and Scalable ColdFusion Applications Using Terrac...
Developing High Performance and Scalable ColdFusion Applications Using Terrac...Developing High Performance and Scalable ColdFusion Applications Using Terrac...
Developing High Performance and Scalable ColdFusion Applications Using Terrac...Shailendra Prasad
 
Hard Caching in TYPO3 - Developer Days in Malmø 2017
Hard Caching in TYPO3 - Developer Days in Malmø 2017Hard Caching in TYPO3 - Developer Days in Malmø 2017
Hard Caching in TYPO3 - Developer Days in Malmø 2017Benni Mack
 
Caching with Memcached and APC
Caching with Memcached and APCCaching with Memcached and APC
Caching with Memcached and APCBen Ramsey
 
CHI - YAPC NA 2012
CHI - YAPC NA 2012CHI - YAPC NA 2012
CHI - YAPC NA 2012jonswar
 
Tachyon_meetup_5-28-2015-IBM
Tachyon_meetup_5-28-2015-IBMTachyon_meetup_5-28-2015-IBM
Tachyon_meetup_5-28-2015-IBMShaoshan Liu
 
Northeast PHP - High Performance PHP
Northeast PHP - High Performance PHPNortheast PHP - High Performance PHP
Northeast PHP - High Performance PHPJonathan Klein
 
Fast Big Data Analytics with Spark on Tachyon
Fast Big Data Analytics with Spark on TachyonFast Big Data Analytics with Spark on Tachyon
Fast Big Data Analytics with Spark on TachyonAlluxio, Inc.
 
Introduction to memcached
Introduction to memcachedIntroduction to memcached
Introduction to memcachedJurriaan Persyn
 
7. Key-Value Databases: In Depth
7. Key-Value Databases: In Depth7. Key-Value Databases: In Depth
7. Key-Value Databases: In DepthFabio Fumarola
 
NYJavaSIG - Big Data Microservices w/ Speedment
NYJavaSIG - Big Data Microservices w/ SpeedmentNYJavaSIG - Big Data Microservices w/ Speedment
NYJavaSIG - Big Data Microservices w/ SpeedmentSpeedment, Inc.
 
JavaOne2016 - Microservices: Terabytes in Microseconds [CON4516]
JavaOne2016 - Microservices: Terabytes in Microseconds [CON4516]JavaOne2016 - Microservices: Terabytes in Microseconds [CON4516]
JavaOne2016 - Microservices: Terabytes in Microseconds [CON4516]Speedment, Inc.
 
JavaOne2016 - Microservices: Terabytes in Microseconds [CON4516]
JavaOne2016 - Microservices: Terabytes in Microseconds [CON4516]JavaOne2016 - Microservices: Terabytes in Microseconds [CON4516]
JavaOne2016 - Microservices: Terabytes in Microseconds [CON4516]Malin Weiss
 
Aerospike Go Language Client
Aerospike Go Language ClientAerospike Go Language Client
Aerospike Go Language ClientSayyaparaju Sunil
 
Java In-Process Caching - Performance, Progress and Pittfalls
Java In-Process Caching - Performance, Progress and PittfallsJava In-Process Caching - Performance, Progress and Pittfalls
Java In-Process Caching - Performance, Progress and Pittfallscruftex
 
Java In-Process Caching - Performance, Progress and Pitfalls
Java In-Process Caching - Performance, Progress and PitfallsJava In-Process Caching - Performance, Progress and Pitfalls
Java In-Process Caching - Performance, Progress and PitfallsJens Wilke
 
HBaseCon 2015: HBase at Scale in an Online and High-Demand Environment
HBaseCon 2015: HBase at Scale in an Online and  High-Demand EnvironmentHBaseCon 2015: HBase at Scale in an Online and  High-Demand Environment
HBaseCon 2015: HBase at Scale in an Online and High-Demand EnvironmentHBaseCon
 
Performance Optimization using Caching | Swatantra Kumar
Performance Optimization using Caching | Swatantra KumarPerformance Optimization using Caching | Swatantra Kumar
Performance Optimization using Caching | Swatantra KumarSwatantra Kumar
 
High availability system cache and queue - Write behind
High availability system cache and queue - Write behindHigh availability system cache and queue - Write behind
High availability system cache and queue - Write behindLe Kien Truc
 

Similar to CREAM - That Conference Austin - January 2024.pptx (20)

Open source: Top issues in the top enterprise packages
Open source: Top issues in the top enterprise packagesOpen source: Top issues in the top enterprise packages
Open source: Top issues in the top enterprise packages
 
Developing High Performance and Scalable ColdFusion Application Using Terraco...
Developing High Performance and Scalable ColdFusion Application Using Terraco...Developing High Performance and Scalable ColdFusion Application Using Terraco...
Developing High Performance and Scalable ColdFusion Application Using Terraco...
 
Developing High Performance and Scalable ColdFusion Applications Using Terrac...
Developing High Performance and Scalable ColdFusion Applications Using Terrac...Developing High Performance and Scalable ColdFusion Applications Using Terrac...
Developing High Performance and Scalable ColdFusion Applications Using Terrac...
 
Hard Caching in TYPO3 - Developer Days in Malmø 2017
Hard Caching in TYPO3 - Developer Days in Malmø 2017Hard Caching in TYPO3 - Developer Days in Malmø 2017
Hard Caching in TYPO3 - Developer Days in Malmø 2017
 
Caching with Memcached and APC
Caching with Memcached and APCCaching with Memcached and APC
Caching with Memcached and APC
 
CHI - YAPC NA 2012
CHI - YAPC NA 2012CHI - YAPC NA 2012
CHI - YAPC NA 2012
 
Tachyon_meetup_5-28-2015-IBM
Tachyon_meetup_5-28-2015-IBMTachyon_meetup_5-28-2015-IBM
Tachyon_meetup_5-28-2015-IBM
 
Northeast PHP - High Performance PHP
Northeast PHP - High Performance PHPNortheast PHP - High Performance PHP
Northeast PHP - High Performance PHP
 
Fast Big Data Analytics with Spark on Tachyon
Fast Big Data Analytics with Spark on TachyonFast Big Data Analytics with Spark on Tachyon
Fast Big Data Analytics with Spark on Tachyon
 
Introduction to memcached
Introduction to memcachedIntroduction to memcached
Introduction to memcached
 
7. Key-Value Databases: In Depth
7. Key-Value Databases: In Depth7. Key-Value Databases: In Depth
7. Key-Value Databases: In Depth
 
NYJavaSIG - Big Data Microservices w/ Speedment
NYJavaSIG - Big Data Microservices w/ SpeedmentNYJavaSIG - Big Data Microservices w/ Speedment
NYJavaSIG - Big Data Microservices w/ Speedment
 
JavaOne2016 - Microservices: Terabytes in Microseconds [CON4516]
JavaOne2016 - Microservices: Terabytes in Microseconds [CON4516]JavaOne2016 - Microservices: Terabytes in Microseconds [CON4516]
JavaOne2016 - Microservices: Terabytes in Microseconds [CON4516]
 
JavaOne2016 - Microservices: Terabytes in Microseconds [CON4516]
JavaOne2016 - Microservices: Terabytes in Microseconds [CON4516]JavaOne2016 - Microservices: Terabytes in Microseconds [CON4516]
JavaOne2016 - Microservices: Terabytes in Microseconds [CON4516]
 
Aerospike Go Language Client
Aerospike Go Language ClientAerospike Go Language Client
Aerospike Go Language Client
 
Java In-Process Caching - Performance, Progress and Pittfalls
Java In-Process Caching - Performance, Progress and PittfallsJava In-Process Caching - Performance, Progress and Pittfalls
Java In-Process Caching - Performance, Progress and Pittfalls
 
Java In-Process Caching - Performance, Progress and Pitfalls
Java In-Process Caching - Performance, Progress and PitfallsJava In-Process Caching - Performance, Progress and Pitfalls
Java In-Process Caching - Performance, Progress and Pitfalls
 
HBaseCon 2015: HBase at Scale in an Online and High-Demand Environment
HBaseCon 2015: HBase at Scale in an Online and  High-Demand EnvironmentHBaseCon 2015: HBase at Scale in an Online and  High-Demand Environment
HBaseCon 2015: HBase at Scale in an Online and High-Demand Environment
 
Performance Optimization using Caching | Swatantra Kumar
Performance Optimization using Caching | Swatantra KumarPerformance Optimization using Caching | Swatantra Kumar
Performance Optimization using Caching | Swatantra Kumar
 
High availability system cache and queue - Write behind
High availability system cache and queue - Write behindHigh availability system cache and queue - Write behind
High availability system cache and queue - Write behind
 

More from Matthew Groves

FluentMigrator - Dayton .NET - July 2023
FluentMigrator - Dayton .NET - July 2023FluentMigrator - Dayton .NET - July 2023
FluentMigrator - Dayton .NET - July 2023Matthew Groves
 
Putting the SQL Back in NoSQL - October 2022 - All Things Open
Putting the SQL Back in NoSQL - October 2022 - All Things OpenPutting the SQL Back in NoSQL - October 2022 - All Things Open
Putting the SQL Back in NoSQL - October 2022 - All Things OpenMatthew Groves
 
Don't Drop ACID (July 2021)
Don't Drop ACID (July 2021)Don't Drop ACID (July 2021)
Don't Drop ACID (July 2021)Matthew Groves
 
Don't Drop ACID - Data Love - April 2021
Don't Drop ACID - Data Love - April 2021Don't Drop ACID - Data Love - April 2021
Don't Drop ACID - Data Love - April 2021Matthew Groves
 
Demystifying NoSQL - All Things Open - October 2020
Demystifying NoSQL - All Things Open - October 2020Demystifying NoSQL - All Things Open - October 2020
Demystifying NoSQL - All Things Open - October 2020Matthew Groves
 
Autonomous Microservices - Manning - July 2020
Autonomous Microservices - Manning - July 2020Autonomous Microservices - Manning - July 2020
Autonomous Microservices - Manning - July 2020Matthew Groves
 
CONDG April 23 2020 - Baskar Rao - GraphQL
CONDG April 23 2020 - Baskar Rao - GraphQLCONDG April 23 2020 - Baskar Rao - GraphQL
CONDG April 23 2020 - Baskar Rao - GraphQLMatthew Groves
 
JSON Data Modeling - GDG Indy - April 2020
JSON Data Modeling - GDG Indy - April 2020JSON Data Modeling - GDG Indy - April 2020
JSON Data Modeling - GDG Indy - April 2020Matthew Groves
 
Background Tasks Without a Separate Service: Hangfire for ASP.NET - KCDC - Ju...
Background Tasks Without a Separate Service: Hangfire for ASP.NET - KCDC - Ju...Background Tasks Without a Separate Service: Hangfire for ASP.NET - KCDC - Ju...
Background Tasks Without a Separate Service: Hangfire for ASP.NET - KCDC - Ju...Matthew Groves
 
Intro to SQL++ - Detroit Tech Watch - June 2019
Intro to SQL++ - Detroit Tech Watch - June 2019Intro to SQL++ - Detroit Tech Watch - June 2019
Intro to SQL++ - Detroit Tech Watch - June 2019Matthew Groves
 
Autonomous Microservices - CodeMash - January 2019
Autonomous Microservices - CodeMash - January 2019Autonomous Microservices - CodeMash - January 2019
Autonomous Microservices - CodeMash - January 2019Matthew Groves
 
5 Popular Choices for NoSQL on a Microsoft Platform - Tulsa - July 2018
5 Popular Choices for NoSQL on a Microsoft Platform - Tulsa - July 20185 Popular Choices for NoSQL on a Microsoft Platform - Tulsa - July 2018
5 Popular Choices for NoSQL on a Microsoft Platform - Tulsa - July 2018Matthew Groves
 
JSON Data Modeling - July 2018 - Tulsa Techfest
JSON Data Modeling - July 2018 - Tulsa TechfestJSON Data Modeling - July 2018 - Tulsa Techfest
JSON Data Modeling - July 2018 - Tulsa TechfestMatthew Groves
 
5 NoSQL Options - Toronto - May 2018
5 NoSQL Options - Toronto - May 20185 NoSQL Options - Toronto - May 2018
5 NoSQL Options - Toronto - May 2018Matthew Groves
 
Full stack development with node and NoSQL - All Things Open - October 2017
Full stack development with node and NoSQL - All Things Open - October 2017Full stack development with node and NoSQL - All Things Open - October 2017
Full stack development with node and NoSQL - All Things Open - October 2017Matthew Groves
 
5 Popular Choices for NoSQL on a Microsoft Platform - All Things Open - Octob...
5 Popular Choices for NoSQL on a Microsoft Platform - All Things Open - Octob...5 Popular Choices for NoSQL on a Microsoft Platform - All Things Open - Octob...
5 Popular Choices for NoSQL on a Microsoft Platform - All Things Open - Octob...Matthew Groves
 
I Have a NoSQL toaster - DC - August 2017
I Have a NoSQL toaster - DC - August 2017I Have a NoSQL toaster - DC - August 2017
I Have a NoSQL toaster - DC - August 2017Matthew Groves
 
Querying NoSQL with SQL - KCDC - August 2017
Querying NoSQL with SQL - KCDC - August 2017Querying NoSQL with SQL - KCDC - August 2017
Querying NoSQL with SQL - KCDC - August 2017Matthew Groves
 
I Have a NoSQL Toaster - Troy .NET User Group - July 2017
I Have a NoSQL Toaster - Troy .NET User Group - July 2017I Have a NoSQL Toaster - Troy .NET User Group - July 2017
I Have a NoSQL Toaster - Troy .NET User Group - July 2017Matthew Groves
 
Querying NoSQL with SQL - MIGANG - July 2017
Querying NoSQL with SQL - MIGANG - July 2017Querying NoSQL with SQL - MIGANG - July 2017
Querying NoSQL with SQL - MIGANG - July 2017Matthew Groves
 

More from Matthew Groves (20)

FluentMigrator - Dayton .NET - July 2023
FluentMigrator - Dayton .NET - July 2023FluentMigrator - Dayton .NET - July 2023
FluentMigrator - Dayton .NET - July 2023
 
Putting the SQL Back in NoSQL - October 2022 - All Things Open
Putting the SQL Back in NoSQL - October 2022 - All Things OpenPutting the SQL Back in NoSQL - October 2022 - All Things Open
Putting the SQL Back in NoSQL - October 2022 - All Things Open
 
Don't Drop ACID (July 2021)
Don't Drop ACID (July 2021)Don't Drop ACID (July 2021)
Don't Drop ACID (July 2021)
 
Don't Drop ACID - Data Love - April 2021
Don't Drop ACID - Data Love - April 2021Don't Drop ACID - Data Love - April 2021
Don't Drop ACID - Data Love - April 2021
 
Demystifying NoSQL - All Things Open - October 2020
Demystifying NoSQL - All Things Open - October 2020Demystifying NoSQL - All Things Open - October 2020
Demystifying NoSQL - All Things Open - October 2020
 
Autonomous Microservices - Manning - July 2020
Autonomous Microservices - Manning - July 2020Autonomous Microservices - Manning - July 2020
Autonomous Microservices - Manning - July 2020
 
CONDG April 23 2020 - Baskar Rao - GraphQL
CONDG April 23 2020 - Baskar Rao - GraphQLCONDG April 23 2020 - Baskar Rao - GraphQL
CONDG April 23 2020 - Baskar Rao - GraphQL
 
JSON Data Modeling - GDG Indy - April 2020
JSON Data Modeling - GDG Indy - April 2020JSON Data Modeling - GDG Indy - April 2020
JSON Data Modeling - GDG Indy - April 2020
 
Background Tasks Without a Separate Service: Hangfire for ASP.NET - KCDC - Ju...
Background Tasks Without a Separate Service: Hangfire for ASP.NET - KCDC - Ju...Background Tasks Without a Separate Service: Hangfire for ASP.NET - KCDC - Ju...
Background Tasks Without a Separate Service: Hangfire for ASP.NET - KCDC - Ju...
 
Intro to SQL++ - Detroit Tech Watch - June 2019
Intro to SQL++ - Detroit Tech Watch - June 2019Intro to SQL++ - Detroit Tech Watch - June 2019
Intro to SQL++ - Detroit Tech Watch - June 2019
 
Autonomous Microservices - CodeMash - January 2019
Autonomous Microservices - CodeMash - January 2019Autonomous Microservices - CodeMash - January 2019
Autonomous Microservices - CodeMash - January 2019
 
5 Popular Choices for NoSQL on a Microsoft Platform - Tulsa - July 2018
5 Popular Choices for NoSQL on a Microsoft Platform - Tulsa - July 20185 Popular Choices for NoSQL on a Microsoft Platform - Tulsa - July 2018
5 Popular Choices for NoSQL on a Microsoft Platform - Tulsa - July 2018
 
JSON Data Modeling - July 2018 - Tulsa Techfest
JSON Data Modeling - July 2018 - Tulsa TechfestJSON Data Modeling - July 2018 - Tulsa Techfest
JSON Data Modeling - July 2018 - Tulsa Techfest
 
5 NoSQL Options - Toronto - May 2018
5 NoSQL Options - Toronto - May 20185 NoSQL Options - Toronto - May 2018
5 NoSQL Options - Toronto - May 2018
 
Full stack development with node and NoSQL - All Things Open - October 2017
Full stack development with node and NoSQL - All Things Open - October 2017Full stack development with node and NoSQL - All Things Open - October 2017
Full stack development with node and NoSQL - All Things Open - October 2017
 
5 Popular Choices for NoSQL on a Microsoft Platform - All Things Open - Octob...
5 Popular Choices for NoSQL on a Microsoft Platform - All Things Open - Octob...5 Popular Choices for NoSQL on a Microsoft Platform - All Things Open - Octob...
5 Popular Choices for NoSQL on a Microsoft Platform - All Things Open - Octob...
 
I Have a NoSQL toaster - DC - August 2017
I Have a NoSQL toaster - DC - August 2017I Have a NoSQL toaster - DC - August 2017
I Have a NoSQL toaster - DC - August 2017
 
Querying NoSQL with SQL - KCDC - August 2017
Querying NoSQL with SQL - KCDC - August 2017Querying NoSQL with SQL - KCDC - August 2017
Querying NoSQL with SQL - KCDC - August 2017
 
I Have a NoSQL Toaster - Troy .NET User Group - July 2017
I Have a NoSQL Toaster - Troy .NET User Group - July 2017I Have a NoSQL Toaster - Troy .NET User Group - July 2017
I Have a NoSQL Toaster - Troy .NET User Group - July 2017
 
Querying NoSQL with SQL - MIGANG - July 2017
Querying NoSQL with SQL - MIGANG - July 2017Querying NoSQL with SQL - MIGANG - July 2017
Querying NoSQL with SQL - MIGANG - July 2017
 

Recently uploaded

VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130
VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130
VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130Suhani Kapoor
 
ASML's Taxonomy Adventure by Daniel Canter
ASML's Taxonomy Adventure by Daniel CanterASML's Taxonomy Adventure by Daniel Canter
ASML's Taxonomy Adventure by Daniel Cantervoginip
 
dokumen.tips_chapter-4-transient-heat-conduction-mehmet-kanoglu.ppt
dokumen.tips_chapter-4-transient-heat-conduction-mehmet-kanoglu.pptdokumen.tips_chapter-4-transient-heat-conduction-mehmet-kanoglu.ppt
dokumen.tips_chapter-4-transient-heat-conduction-mehmet-kanoglu.pptSonatrach
 
Effects of Smartphone Addiction on the Academic Performances of Grades 9 to 1...
Effects of Smartphone Addiction on the Academic Performances of Grades 9 to 1...Effects of Smartphone Addiction on the Academic Performances of Grades 9 to 1...
Effects of Smartphone Addiction on the Academic Performances of Grades 9 to 1...limedy534
 
专业一比一美国俄亥俄大学毕业证成绩单pdf电子版制作修改
专业一比一美国俄亥俄大学毕业证成绩单pdf电子版制作修改专业一比一美国俄亥俄大学毕业证成绩单pdf电子版制作修改
专业一比一美国俄亥俄大学毕业证成绩单pdf电子版制作修改yuu sss
 
RA-11058_IRR-COMPRESS Do 198 series of 1998
RA-11058_IRR-COMPRESS Do 198 series of 1998RA-11058_IRR-COMPRESS Do 198 series of 1998
RA-11058_IRR-COMPRESS Do 198 series of 1998YohFuh
 
办理学位证中佛罗里达大学毕业证,UCF成绩单原版一比一
办理学位证中佛罗里达大学毕业证,UCF成绩单原版一比一办理学位证中佛罗里达大学毕业证,UCF成绩单原版一比一
办理学位证中佛罗里达大学毕业证,UCF成绩单原版一比一F sss
 
PKS-TGC-1084-630 - Stage 1 Proposal.pptx
PKS-TGC-1084-630 - Stage 1 Proposal.pptxPKS-TGC-1084-630 - Stage 1 Proposal.pptx
PKS-TGC-1084-630 - Stage 1 Proposal.pptxPramod Kumar Srivastava
 
9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort service
9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort service9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort service
9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort servicejennyeacort
 
INTERNSHIP ON PURBASHA COMPOSITE TEX LTD
INTERNSHIP ON PURBASHA COMPOSITE TEX LTDINTERNSHIP ON PURBASHA COMPOSITE TEX LTD
INTERNSHIP ON PURBASHA COMPOSITE TEX LTDRafezzaman
 
Beautiful Sapna Vip Call Girls Hauz Khas 9711199012 Call /Whatsapps
Beautiful Sapna Vip  Call Girls Hauz Khas 9711199012 Call /WhatsappsBeautiful Sapna Vip  Call Girls Hauz Khas 9711199012 Call /Whatsapps
Beautiful Sapna Vip Call Girls Hauz Khas 9711199012 Call /Whatsappssapnasaifi408
 
Customer Service Analytics - Make Sense of All Your Data.pptx
Customer Service Analytics - Make Sense of All Your Data.pptxCustomer Service Analytics - Make Sense of All Your Data.pptx
Customer Service Analytics - Make Sense of All Your Data.pptxEmmanuel Dauda
 
Brighton SEO | April 2024 | Data Storytelling
Brighton SEO | April 2024 | Data StorytellingBrighton SEO | April 2024 | Data Storytelling
Brighton SEO | April 2024 | Data StorytellingNeil Barnes
 
9654467111 Call Girls In Munirka Hotel And Home Service
9654467111 Call Girls In Munirka Hotel And Home Service9654467111 Call Girls In Munirka Hotel And Home Service
9654467111 Call Girls In Munirka Hotel And Home ServiceSapana Sha
 
RS 9000 Call In girls Dwarka Mor (DELHI)⇛9711147426🔝Delhi
RS 9000 Call In girls Dwarka Mor (DELHI)⇛9711147426🔝DelhiRS 9000 Call In girls Dwarka Mor (DELHI)⇛9711147426🔝Delhi
RS 9000 Call In girls Dwarka Mor (DELHI)⇛9711147426🔝Delhijennyeacort
 
毕业文凭制作#回国入职#diploma#degree澳洲中央昆士兰大学毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#degree
毕业文凭制作#回国入职#diploma#degree澳洲中央昆士兰大学毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#degree毕业文凭制作#回国入职#diploma#degree澳洲中央昆士兰大学毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#degree
毕业文凭制作#回国入职#diploma#degree澳洲中央昆士兰大学毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#degreeyuu sss
 
Kantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdf
Kantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdfKantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdf
Kantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdfSocial Samosa
 
1:1定制(UQ毕业证)昆士兰大学毕业证成绩单修改留信学历认证原版一模一样
1:1定制(UQ毕业证)昆士兰大学毕业证成绩单修改留信学历认证原版一模一样1:1定制(UQ毕业证)昆士兰大学毕业证成绩单修改留信学历认证原版一模一样
1:1定制(UQ毕业证)昆士兰大学毕业证成绩单修改留信学历认证原版一模一样vhwb25kk
 

Recently uploaded (20)

VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130
VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130
VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130
 
ASML's Taxonomy Adventure by Daniel Canter
ASML's Taxonomy Adventure by Daniel CanterASML's Taxonomy Adventure by Daniel Canter
ASML's Taxonomy Adventure by Daniel Canter
 
dokumen.tips_chapter-4-transient-heat-conduction-mehmet-kanoglu.ppt
dokumen.tips_chapter-4-transient-heat-conduction-mehmet-kanoglu.pptdokumen.tips_chapter-4-transient-heat-conduction-mehmet-kanoglu.ppt
dokumen.tips_chapter-4-transient-heat-conduction-mehmet-kanoglu.ppt
 
Effects of Smartphone Addiction on the Academic Performances of Grades 9 to 1...
Effects of Smartphone Addiction on the Academic Performances of Grades 9 to 1...Effects of Smartphone Addiction on the Academic Performances of Grades 9 to 1...
Effects of Smartphone Addiction on the Academic Performances of Grades 9 to 1...
 
专业一比一美国俄亥俄大学毕业证成绩单pdf电子版制作修改
专业一比一美国俄亥俄大学毕业证成绩单pdf电子版制作修改专业一比一美国俄亥俄大学毕业证成绩单pdf电子版制作修改
专业一比一美国俄亥俄大学毕业证成绩单pdf电子版制作修改
 
Call Girls in Saket 99530🔝 56974 Escort Service
Call Girls in Saket 99530🔝 56974 Escort ServiceCall Girls in Saket 99530🔝 56974 Escort Service
Call Girls in Saket 99530🔝 56974 Escort Service
 
RA-11058_IRR-COMPRESS Do 198 series of 1998
RA-11058_IRR-COMPRESS Do 198 series of 1998RA-11058_IRR-COMPRESS Do 198 series of 1998
RA-11058_IRR-COMPRESS Do 198 series of 1998
 
Deep Generative Learning for All - The Gen AI Hype (Spring 2024)
Deep Generative Learning for All - The Gen AI Hype (Spring 2024)Deep Generative Learning for All - The Gen AI Hype (Spring 2024)
Deep Generative Learning for All - The Gen AI Hype (Spring 2024)
 
办理学位证中佛罗里达大学毕业证,UCF成绩单原版一比一
办理学位证中佛罗里达大学毕业证,UCF成绩单原版一比一办理学位证中佛罗里达大学毕业证,UCF成绩单原版一比一
办理学位证中佛罗里达大学毕业证,UCF成绩单原版一比一
 
PKS-TGC-1084-630 - Stage 1 Proposal.pptx
PKS-TGC-1084-630 - Stage 1 Proposal.pptxPKS-TGC-1084-630 - Stage 1 Proposal.pptx
PKS-TGC-1084-630 - Stage 1 Proposal.pptx
 
9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort service
9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort service9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort service
9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort service
 
INTERNSHIP ON PURBASHA COMPOSITE TEX LTD
INTERNSHIP ON PURBASHA COMPOSITE TEX LTDINTERNSHIP ON PURBASHA COMPOSITE TEX LTD
INTERNSHIP ON PURBASHA COMPOSITE TEX LTD
 
Beautiful Sapna Vip Call Girls Hauz Khas 9711199012 Call /Whatsapps
Beautiful Sapna Vip  Call Girls Hauz Khas 9711199012 Call /WhatsappsBeautiful Sapna Vip  Call Girls Hauz Khas 9711199012 Call /Whatsapps
Beautiful Sapna Vip Call Girls Hauz Khas 9711199012 Call /Whatsapps
 
Customer Service Analytics - Make Sense of All Your Data.pptx
Customer Service Analytics - Make Sense of All Your Data.pptxCustomer Service Analytics - Make Sense of All Your Data.pptx
Customer Service Analytics - Make Sense of All Your Data.pptx
 
Brighton SEO | April 2024 | Data Storytelling
Brighton SEO | April 2024 | Data StorytellingBrighton SEO | April 2024 | Data Storytelling
Brighton SEO | April 2024 | Data Storytelling
 
9654467111 Call Girls In Munirka Hotel And Home Service
9654467111 Call Girls In Munirka Hotel And Home Service9654467111 Call Girls In Munirka Hotel And Home Service
9654467111 Call Girls In Munirka Hotel And Home Service
 
RS 9000 Call In girls Dwarka Mor (DELHI)⇛9711147426🔝Delhi
RS 9000 Call In girls Dwarka Mor (DELHI)⇛9711147426🔝DelhiRS 9000 Call In girls Dwarka Mor (DELHI)⇛9711147426🔝Delhi
RS 9000 Call In girls Dwarka Mor (DELHI)⇛9711147426🔝Delhi
 
毕业文凭制作#回国入职#diploma#degree澳洲中央昆士兰大学毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#degree
毕业文凭制作#回国入职#diploma#degree澳洲中央昆士兰大学毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#degree毕业文凭制作#回国入职#diploma#degree澳洲中央昆士兰大学毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#degree
毕业文凭制作#回国入职#diploma#degree澳洲中央昆士兰大学毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#degree
 
Kantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdf
Kantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdfKantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdf
Kantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdf
 
1:1定制(UQ毕业证)昆士兰大学毕业证成绩单修改留信学历认证原版一模一样
1:1定制(UQ毕业证)昆士兰大学毕业证成绩单修改留信学历认证原版一模一样1:1定制(UQ毕业证)昆士兰大学毕业证成绩单修改留信学历认证原版一模一样
1:1定制(UQ毕业证)昆士兰大学毕业证成绩单修改留信学历认证原版一模一样
 

CREAM - That Conference Austin - January 2024.pptx

  • 1.
  • 2.
  • 3. C.R.E.A.M. get the memory (dollar dollar bill ya'll) January 2024 Matthew D. Groves | DevRel Engineer aka “Passionate Bravo” Cache Rules Everything Around Me
  • 4. 4 Latency Numbers Every Programmer Should Know https://stackoverflow.com/questions/4087280/approximate-cost-to-access-various-caches-and-main-memory/4087315#4087315
  • 5. 5 The Need for Speed https://www.slideshare.net/devonauerswald/walmart-pagespeedslide
  • 6. 6 Cache Rules Everything Around Me Dollar dollar bill ya'll Android apps iPhone apps CPU cache CDNs Web browser DNS
  • 7. 01/ 02/ 03/ 04/ 05/ 06/ What is caching? Use Cases Reading from Cache Writing into Cache Cache Invalidation Gotchas Agenda
  • 8. 8 ho am I? • Matthew D. Groves • Microsoft MVP, author at Pluralsight, Manning, Apress • DevRel Engineer at Couchbase • https://twitter.com/mgroves • https://www.linkedin.com/in/mgroves/ • C# Advent: https://csadvent.christmas/
  • 9. 9 1 hat is Caching?
  • 10. 10 Caching Collection of duplicated data to serve future requests faster. • First formally described by Maurice Wilkes in 1965 • "Slave Memories and Dynamic Storage Allocation" https://bit.ly/WilkesPaper What is Caching? Key Data 1 Proteck Ya Neck 2 C.R.E.A.M. 3 Brooklyn Zoo 4 Criminology … … Key Data 2 C.R.E.A.M. 4 Criminology Records Cache
  • 11. 11 Powerpoint as a Cache What is Caching? Key Value What year was Wu-Tang Clan Formed? 1992
  • 13. 13 Caching Use Cases What is Caching used for?
  • 14. 14 Caching Use Case 1: Faster Database Access • Databases can rely heavily on disk • Reading the same data over again could mean accessing the disk over again • Store frequently accessed data in a cache, to reduce pressure on database/disk
  • 15. 15 Caching Use Case 1: Faster Database Access DATABASE APP LAN CACHE CACHE CACHE
  • 16. 16 Caching Use Case 2: Faster Web Browsing • Any given URL could result in hundreds of files that are loaded over HTTP • A single JS file may be loaded by every page on a site. • Cache static assets (JS, images, sound, icons, etc) on a user's laptop to avoid loading them over the network every time
  • 17. 17 Caching Use Case 2: Faster Web Browsing CACHE
  • 18. 18 Caching Use Case 3: Efficient API Use • API usage may involve an internet call (with latency) • API calls may cost per use, or may be limited • Storing results in cache may help reduce latency AND reduce costs
  • 19. 19 Caching Use Case 3: Efficient API Use API APP LAN/WAN CACHE CACHE CACHE
  • 20. 20 Caching Use Case 4: Microservice Availability • Retrieving data from other processes • Latency is secondary concern
  • 21. 21 Caching Use Case 4: Microservice Availability CACHE
  • 22. 22 Cache Rules Everything Around Me Dollar dollar bill ya'll Disconnected Availability Slow Repetition Constrained Costs
  • 24. 24 Using a Cache 101 Your Code Key Value A Protect Ya Neck B C.R.E.A.M. C Brooklyn Zoo Cache Key Value A Protect Ya Neck B C.R.E.A.M. C Brooklyn Zoo D Criminology E Triumph F Uzi G Method Man H Wu-Tang Clan Ain't . . . . . . . . . Database 1. Lookup "A" 2. Lookup "B" 3. Lookup "C" HIT! HIT! MISS! 4. Lookup "C" again? WALK OF SHAME
  • 26. 26 What about writes? • Data is duplicated, stored in cache and record • The system is responsible for keeping the cache updated • Commons methods: • write-through • write-around • write-back Stuff needs to get in the cache somehow
  • 27. 27 write-through 1. System gets a new/updated piece of data 2. Write to cache and record "at the same time" a) Write to record b) If that didn't succeed, the write failed. c) Write to cache d) If that didn't succeed, the write failed. Rollback (a). e) If the system reaches this point, the write succeeded! Why or why not use this?
  • 28. 28 write-around 1. System gets a new/updated piece of data 2. Write the data to the record ONLY 3. Invalidate the record in the cache Why or why not use this?
  • 29. 29 write-back 1. System gets a new/updated piece of data 2. Write the data to the cache. 3. Update the record asynchronously (don't wait on it to finish) 4. If the cache write succeeded, then consider the write succeeded. Why or why not use this?
  • 30. 30 Cache Writing Methods Method Write performance Write integrity Best for…? write-through ➖ ➕ High % reads write-around ➖ ➕ High % read later write-back ➕ ❔ Mixed reads / writes
  • 31. 31 Couchbase: A write-back implementation A database with a built-in managed cache https://docs.couchbase.com/server/current/learn/buckets-memory-and-storage/memory-and-storage.html Other Couchbase Server nodes
  • 32. 32 Couchbase and Writing to the Cache await collection.InsertAsync("A", new { title = "Protect Ya Neck" }); await collection.InsertAsync("A", new { title = "Protect Ya Neck" }, options => { options.Durability(DurabilityLevel.None); // OR: options.Durability(DurabilityLevel.Majority); // OR: options.Durability(DurabilityLevel.MajorityAndPersistToActive); // OR: options.Durability(DurabilityLevel.PersistToMajority); });
  • 33. 33 Durability (with 3 replicas) None Memory Disk Node 1 Node 2 Node 3 ✔ ⚠ ⚠ ⚠ ⚠ ⚠ Node 4 ⚠ ⚠
  • 34. 34 Durability (with 3 replicas) Majority Memory Disk Node 1 Node 2 Node 3 ✔ ⚠ ⚠ ⚠ ✔ ⚠ Node 4 ✔ ⚠
  • 35. 35 Durability (with 3 replicas) MajorityAndPersistToActive Memory Disk Node 1 Node 2 Node 3 ✔ ✔ ⚠ ⚠ ✔ ⚠ Node 4 ✔ ⚠
  • 36. 36 Durability (with 3 replicas) PersistToMajority Memory Disk Node 1 Node 2 Node 3 ✔ ✔ ⚠ ⚠ ✔ ✔ Node 4 ✔ ✔
  • 37. 37 Latency Numbers Every Programmer Should Know https://stackoverflow.com/questions/4087280/approximate-cost-to-access-various-caches-and-main-memory/4087315#4087315
  • 39. 39 Powerpoint as a Cache Key Value What year was Wu-Tang Clan Formed? 1992 What was Wu-Tang's first album called? Enter the Wu-Tang What year was Maurice Wilkes born? 1913 What year did Maurice Wilkes die? 2010 What is the most recent Wu- Tang studio album? Once Upon a Time in Shaolin
  • 40. 40 Cache Invalidation is Hard There are only two hard things in Computer Science: cache invalidation and naming things. -- Phil Karlton How to decide what to invalidate (what data to "evict"): cache policy https://www.nndb.com/people/400/000031307/
  • 41. 41 Cache Policy 1: LRU (Least Recently Used) Key How new? A 0 B 1 3 C 2 D 4 Cache max size: 3 Order of reads: A, B, C, B, D X ---------------------------------------------------------------------------------
  • 42. 42 Cache Policy 2: NRU (Not Recently Used) Lower scores evicted (at random) Key Referenced? Modified? Score A 0 0 0 B 0 0 0 C 0 1 1 D 1 0 2 E 1 1 3
  • 43. 43 Cache Policy 3: None Don't evict anything
  • 44. 44 More Cache Policies • RR – random replacement • FIFO and LIFO – treat a cache like a queue • MRU – MOST recently used • LFU – least frequently used • Belady's algorithm – not possible to implement • Machine learning • https://en.wikipedia.org/wiki/Cache_replacement_policies
  • 46. 46 Gotcha 1: Cache Size • Problem: too small or too big cache • Symptom: High turnover and churn (many evictions) or long lifetimes (few evictions) • Solutions: • Monitoring • Size the cache • "Value" vs "Full" eviction
  • 47. 47 Gotcha 2: "Close" Caching • Problem: running the cache on the same machine as the application • Symptom: redundancy, hot spots, inconsistency, availability • Solutions: • Use a distributed cache • Running on its own machine(s) / cluster • Couchbase, of course!
  • 48. 48 Gotcha 3: Bad Eviction Policy • Problem: using the wrong eviction policy • Symptom: lots of overhead, cache checking • Solutions: • Don't Write an Eviction Policy (or better yet don't write a Cache) • Benchmarking: "hit ratio" and "latency" • "Hit ratio" – how often a hit vs miss (e.g. "45% hit ratio") • "Latency" – how long it takes from request to response (e.g. 10μs latency)
  • 50. 50 References • https://www.geeksforgeeks.org/not-recently-used-nru-page-replacement-algorithm/ • https://shahriar.svbtle.com/Understanding-writethrough-writearound-and-writeback- caching-with-python • https://en.wikipedia.org/wiki/Maurice_Wilkes • https://safari.ethz.ch/digitaltechnik/spring2021/lib/exe/fetch.php?media=wilkes.pdf • https://stackoverflow.com/a/4087315/40015 • https://www.techtarget.com/searchstorage/definition/cache • https://en.wikipedia.org/wiki/Cache_replacement_policies • https://docs.couchbase.com/dotnet-sdk/current/howtos/kv-operations.html#durability • https://docs.couchbase.com/dotnet-sdk/current/concept-docs/durability-replication-failure- considerations.html#durable-writes