We use analytics cookies.We use cookies to analyze site traffic and improve your experience.
Loading...
System Design Masterclass · Caching Strategies
Free preview: the first 2 parts of this 8-part lesson.
Already bought the course? Sign in to read the whole lesson.
this lesson is part of
System Design Masterclass
Unlock this lesson and the 751 other paid lessons
$25 once, by PayPal
See the System Design courseread the rest of this lesson in
System Design Masterclass
Unlock this lesson and the 751 other paid lessons
$25 once, by PayPal
See the System Design coursein Caching Strategies
This lesson is part of the full System Design Masterclass. Unlock it along with 769 other lessons for a one-time payment.
One-time payment by card or PayPal
Get Lifetime AccessOne-time payment: UPI, card or netbanking
Get Lifetime Access18 Foundation lessons are free, no payment needed. Try them now
It is easy and good
“It is really nice and good Please join the course”
Four lessons in a row have been about caches spread over machines. Ehcache goes the other way: a library inside one process, with tiers of storage under it. There is no server, no cluster and no protocol.
The obvious question is which of the previous lessons' problems disappear when the network does.

The four on the left were all consequences of the data being somewhere else. The three on the right are consequences of there being more than one copy of something.
Distance and concurrency are different problems, and a local cache only solves the first one. That is the whole lesson, and both halves of it are measured below rather than asserted.

Every number here is from one process on one machine, with no network involved in any of it.

A tiered cache keeps hot entries as live objects and colder ones in a form that has to be decoded before use. That decoding is the whole cost of the second tier, and it is paid on every read.

The intuition is that disk is the expensive tier. In this measurement it is not: the file is small enough that the operating system holds it, so the real work is the decode both lower tiers share.
Read that as a statement about this measurement, not about disks. What transfers is that a serialised tier costs a decode per read, and that cost belongs to the value's complexity, not to the medium it sits on.

In a JVM, every object on the heap is something the garbage collector may have to trace. Holding cached entries as bytes outside the heap removes them from that work entirely.
Producing a plausible number for a garbage collector this lab does not have would be indistinguishable from measuring one, and it would be wrong. The honest version is to say which half was measured.