Sobes.tech
Junior — Senior

Caching strategy in a distributed system

livecode

Task condition

The system uses horizontal sharding of SQL database tables with replication to improve fault tolerance. Formulate and design an approach to caching:

  • Where to place the cache layer (before the database, in the API gateway, inside microservices)?
  • What data to cache: short_link to long_link mapping, frequently requested records, TTLs, etc.
  • What type of cache to use: in-memory (Redis, Memcached), local or distributed?
  • What cache management strategies to apply: TTL, LRU, write-through, write-around, etc.
  • How to ensure data consistency between the cache and the database?