coherence一个重要的参数

   coherence比较小众,网上查询的资料很少。如果生产环境上使用默认的配置,那就会出现问题:

   1. 经常会出现缓存条目被频繁age out出缓存。

   2. 网络流量拥堵。

   以下是默认的设置。

  

      example-binary-backing-map
      HYBRID
      {back-size-limit 0}
      BINARY
      {back-expiry 1h}
     

   

   

      dist-sessionShareCache
      example-distributed
     
       
          back-size-limit
          8MB
       

     

   

   
      dist-default
      example-distributed
     
       
          back-size-limit
          8MB
       

     

   


要想知缓存条目被频繁age out出缓存,就得知道缓存策略。
Optional Specifies the type of eviction policy to use.Legal values are:
■ LRU – Least Recently Used eviction policy chooses which entries to
evict based on how recently they were last accessed, evicting those
that were not accessed the for the longest period first.
■ LFU – Least Frequently Used eviction policy chooses which entries to
evict based on how often they are being accessed, evicting those that
are accessed least frequently first.
■ HYBRID (default) – Hybrid eviction policy chooses which entries to
evict based on the combination (weighted score) of how often and
recently they were accessed, evicting those that are accessed least
frequently and were not accessed for the longest period first.
– A custom eviction policy, specified as a
class-scheme. The class specified within this scheme must implement
the ConfigurableCacheMap.EvictionPolicy interface or extend the
AbstractEvictionPolicy class

看官方文档得小心了,不同的unit-calculator设置单位不同。如果按照默认的设置,缓存只是设置了8M,整个JVM设置的是4G,完全没有用到。
Optional Specifies the type of unit calculator to use. A unit calculator is used to
determine the cost (in "units") of a given object. This element is used only
if the high-units element is set to a positive number. Legal values are:
■ FIXED – A unit calculator that assigns an equal weight of 1 to all
cached objects.
■ BINARY (default) – A unit calculator that assigns an object a weight
equal to the number of bytes of memory that are required to cache
the object
. This calculator is used for Partitioned Caches that cache
data in a binary serialized form. See
com.tangosol.net.cache.BinaryMemoryCalculator for additional
details.
– A custom unit calculator, specified as a
class-scheme. The class specified within this scheme must implement
the
com/tangosol/net/cache/ConfigurableCacheMap.UnitCalculator

interface


那网络的拥堵原因是什么呢?我认为是key被频繁age out,会导致需要频繁的put,况且数据节点之间也需要同步数据,进一步加重的网络的负担。

你可能感兴趣的:(互联网技术)