Caching

Caching topologies

Single in-memory cache

Distributed (client-server) cache

Proprietary protocol is usually based on WebSocket.

Replicated (in-process) cache

Cache on every node contains a replica of cache from another node.

If cache size growth this may be a problem (resources).

Near cache hybrid

  • there is a distributed cache (backing cache)

  • Each node contains a subset of backing cache (it communicates with backing cache)

    • MRU - most recently used

    • MFU - most frequently used

  • client libraries (caches) are not talking to each other

    • they may have different data from one another

Which cache for microservices?

  • Local cache does not fit - because each service will have non consistent cache

  • Near-cache does not fit

    • as far as every service has a subset of cache which is also non consistent => every service will have different response latency (cache on one service has value_1 and returns it quick, cache on another service does not have this value in near cache => request to backing cache is fired => latency is higher)

  • Replicated cache OR Distributed cache is a choice for microservices

Last updated