The Four Patterns Of Data Loading [Link] are about two main trade offs: simplicity for performance, and freshness for execution consistency. This may

Tradeoffs with the Four Patterns Of Data Loading

submited by
Style Pass
2024-05-08 17:00:07

The Four Patterns Of Data Loading [Link] are about two main trade offs: simplicity for performance, and freshness for execution consistency.

This may seem odd because the quadrants are defined by loading and caching strategies, not simplicity, performance or execution consistency.

The decision to use caching is about trading simplicity for performance.  You can simply load the data every time you need it.  If you’re using MySql on AWS, a basic query will take about 2ms to return.  The pattern is very simple and self contained: load data when needed.

Caching, saving data for reuse, improves performance by reducing the time it takes to use the data again.  In exchange, you have to think about your code and determine:

Imagine a simple operation, adding a tag to a contact.  The tag is a string and the contact is represented by an email address.  You need to transform the tag and email into ids and store them in a normalized database table.  For simplicity’s sake, let’s say all DB operations take 2ms.

Using a Read Through Cache, we store the tagId after the first load.  The first operation takes 6ms and each additional operation takes 4ms.

Leave a Comment