As we all know that serving content from memory is always faster than to make a network trip to database to execute a query and then return your desired data. Caching helps in improving overall application performance. Unless you have specific reasons not to cache, you should be caching.
There are many open source cache implementation exists like Hazelcast, memcache, redis,ehcache,Jcache etc. For the purpose of this article we will focus on different cache topologies available with ehcache.
EHCache supports following topologies :
Key Performance Metrics for EHCacheThere are many open source cache implementation exists like Hazelcast, memcache, redis,ehcache,Jcache etc. For the purpose of this article we will focus on different cache topologies available with ehcache.
EHCache supports following topologies :
- Standalone : The cached data set is placed in application JVM/node itself. Any other application node is not aware of already cached data by another node. There are no communication between application nodes for cache synchronization.
- Distributed Cache : In this topology cache data set is placed in Terracotta Server Array with subset of recently used data is placed in each application node. We also refer these local copy of cache as near cache.
- Replicated Cache : Here cached data set is placed in each application node and data is copied or invalidated across cache cluster without locking. If there is a new cache item on one application node , this data set will be replicated across all application node. There are many techniques that can be used to implement replicated cache :
- Cache Replication using RMI
- Cache Replication using Jgroups
- Cache Replication using JMS
- Cache Replication using Cache Server
EHCache expose lots of monitoring metrics. Following metrics can be best answer to measure cache utilization :
- CacheHitPercentage : Percentage of total Hit a particular cache observed
- Cache Hits : If request data is in cache, it is a Hit and this counter increase for every hit.
- CacheMissPercentage : Percentage of total Misses a particular cache observed
- CacheMisses : If request data is not in cache, it is a Miss and this counter increase for every Miss. Request data is then accessed from DB and placed in cache.
- ObjectCount : Total number of Objects in particular cache.
No comments:
Post a Comment