GoConqr has a new look! Let us know what you think.

Notes

caching

ritesh yadav Information Technology English 1 page

Content of the notes (1)

Page 1

Memcache is an example of distributed cache, which is defined as cache maintained in different address space then the object cached, generally the cache is deployed on multiple nodes forming a logical cache

In process cache-->cache maintained in the same address space

ConsiderationsIn-Process CacheDistributed CacheCommentsConsistencyWhile using an in-process cache, your cache elements are local to a single instance of your application. Many medium-to-large applications, however, will not have a single application instance as they will most likely be load-balanced. In such a setting, you will end up with as many caches as your application instances, each having a different state resulting in inconsistency. State may however be eventually consistent as cached items time-out or are evicted from all cache instances.Distributed caches, although deployed on a cluster of multiple nodes, offer a single logical view (and state) of the cache. In most cases, an object stored in a distributed cache cluster will reside on a single node in a distributed cache cluster. By means of a hashing algorithm, the cache engine can always determine on which node a particular key-value resides. Since there is always a single state of the cache cluster, it is never inconsistent.If you are caching immutable objects, consistency ceases to be an issue. In such a case, an in-process cache is a better choice as many overheads typically associated with external distributed caches are simply not there. If your application is deployed on multiple nodes, you cache mutable objects and you want your reads to always be consistent rather than eventually consistent, a distributed cache is the way to go.OverheadsThis dated but very descriptive article describes how an in-process cache can negatively effect performance of an application with an embedded cache primarily due to garbage collection overheads. Your results however are heavily dependent on factors such as the size of the cache and how quickly objects are being evicted and timed-out.A distributed cache will have two major overheads that will make it slower than an in-process cache (but better than not caching at all): network latency and object serializationAs described earlier, if you are looking for an always-consistent global cache state in a multi-node deployment, a distributed cache is what you are looking for (at the cost of performance that you may get from a local in-process cache).ReliabilityAn in-process cache makes use of the same heap space as your program so one has to be careful when determining the upper limits of memory usage for the cache. If your program runs out of memory there is no easy way to recover from it.A distributed cache runs as an independent processes across multiple nodes and therefore failure of a single node does not result in a complete failure of the cache. As a result of a node failure, items that are no longer cached will make their way into surviving nodes on the next cache miss. Also in the case of distributed caches, the worst consequence of a complete cache failure should be degraded performance of the application as opposed to complete system failure.An in-process cache seems like a better option for a small and predictable number of frequently accessed, preferably immutable objects. For large, unpredictable volumes, you are better off with a distributed cache.

For small application with immutable object caching with in process cache is the better choice where as if the object state changes and the application is medium to large the distributed caching is the way forward.

Information

Description
Information Technology Note on caching, created by ritesh yadav on 29/03/2017.
Created by
ritesh yadav · Mar 2017
Updated
Mar 29, 2017
Views
1
Rating

Feedback

What is it about?

What do you think of the new look?

How do you like it?