ElastiCache Strategies

Two Caching Implementation Strategies

  • Lazy Loading / Cache-Aside / Lazy Population

  • WriteThrough

Lazy-Loading

Pros:

  • Only requested data is cached; no useless data

  • Node failures are not fatal (just increased latency to warm cache)

Cons:

  • Cache miss penalty will result in 3 round trips, noticeable delay in initial request

  • Stale data: data can be updated in database and outdated in the cache

WriteThrough

Pros:

  • Data in dcache is never stale, reads are quick

  • Write penalty instead of ready penalty (each write requires 2 calls)

Cons:

  • Missing Data until it is added/updated in the DB. Mitigation is to implement Lazy-Loading strategy in conjunction

  • Cache churn - a lot of the data will never be read into the cache

Managing Cache with Cache Evictions and Time-To-Live (TTL)

Eviction can occur in three ways:

  1. Delete item explicitly in the cache

  2. Item evicted due to full memory and not been recently used (LRU)

  3. Set item time-to-live (TTL)

TTL can range from a few seconds to hours and days.

Last updated

Was this helpful?