AppFabric Cache memory very intensive

2020-04-21 02:42发布

The question(s): Am I doing something wrong? Incorrect config setting? Is the amount of memory usage by AppFabric shown below normal?

The problem: I am reading the data from a SQL database table into AppFabric cache memory. It seems like AppFabric uses a large amount of memory for a fairly small object and I cant understand why(I have recently started using ApppFabric-so I am a noob with it)

Description: A SQL table of about 60MB converts to about 800MB once in AppFabric cache.

Details:

SQL data size of table I intend to load:

SQL data size

App Fabric idle memory usage:

AppFabric idle usage

Server Config:

<?xml version="1.0" encoding="utf-8"?>
    <configuration>
        <configSections>
            <section name="dataCache" type="Microsoft.ApplicationServer.Caching.DataCacheSection, Microsoft.ApplicationServer.Caching.Core" />
        </configSections>
         <dataCache size="Small">
<caches>
  <cache consistency="StrongConsistency" name="MobileCache" minSecondaries="0">
    <policy>
      <eviction type="None" />
      <expiration defaultTTL="1" isExpirable="false" />
    </policy>
  </cache>
  <cache consistency="StrongConsistency" name="default" minSecondaries="0">
    <policy>
      <eviction type="Lru" />
      <expiration defaultTTL="10" isExpirable="true" />
    </policy>
  </cache>
</caches>
<hosts>
  <host replicationPort="22236" arbitrationPort="22235" clusterPort="22234"
    hostId="1073911731" size="1000" leadHost="true" account="BGZA\accName"
    cacheHostName="AppFabricCachingService" name="hostname.domain.co.za"
    cachePort="22233" />
</hosts>
<advancedProperties>
<transportProperties connectionBufferSize="131072" maxBufferPoolSize="2147483647" 
                   maxBufferSize="2147483647" maxOutputDelay="2" channelInitializationTimeout="60000" 
                   receiveTimeout="600000"/>
  <securityProperties>
    <authorization>
      <allow users="Rossp0033" />
    </authorization>
  </securityProperties>
</advancedProperties>
<deploymentSettings>
  <deploymentMode value="RoutingClient" />
</deploymentSettings>

Client Config:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <configSections>
    <section name="dataCacheClient"
         type="Microsoft.ApplicationServer.Caching.DataCacheClientSection, Microsoft.ApplicationServer.Caching.Core,Version=1.0.0.0,Culture=neutral, PublicKeyToken=31bf3856ad364e35"
          allowLocation="true"
          allowDefinition="Everywhere"/>
  </configSections>
  <dataCacheClient>
    <hosts>
      <host
         name="HostName.DomainName.co.za"
         cachePort="22233"/>
    </hosts>
    <transportProperties connectionBufferSize="131072" maxBufferPoolSize="2147483647"
                      maxBufferSize="2147483647" maxOutputDelay="2" channelInitializationTimeout="60000"
                      receiveTimeout="600000"/>
  </dataCacheClient>
  <startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
  </startup> 
</configuration>

The C# code:

public static void ReadPortedNumbers()
{
    MobileDataContext mdc = null;
    List<PortedNumberCollection> col;

    try
    {
        mdc = new MobileDataContext(strConnString);

        col = (from RN in mdc.tblRoutedNumbers
               select Convert(RN)).ToList();

        var CacheFactory = new DataCacheFactory();
        var myCache = CacheFactory.GetCache("MobileCache");

        myCache.Put("PortedNumberCollection", col);

    }
    catch (Exception E)
    {
        throw new System.Exception(E.GetType().ToString() + " in BG.Mobile.DAL.ReadPortedNumbers, Message : " + E.Message, E);
    }
    finally
    {
        if (mdc != null) mdc.Dispose();
    }
}

public static PortedNumberCollection Convert(tblRoutedNumber DataClass)
{
    try
    {
        PortedNumberCollection BusinessClass = new PortedNumberCollection();

        BusinessClass.PortedID = DataClass.PortedID;
        BusinessClass.MSISDN = DataClass.MSISDN;
        BusinessClass.RoutingLabel = DataClass.RoutingLabel;
        BusinessClass.RouteAction = DataClass.RouteAction;

        return BusinessClass;
    }
    catch (Exception E)
    {
        throw new System.Exception(E.GetType().ToString() + " in BG.Bus.Mobile.DALConvertor.Convert(tblRoutedNumber DataClass): " + E.Message);                

    }
}

[DataContract][Serializable]
public class PortedNumberCollection
{
    [DataMember]        
    public Int64 PortedID;

    [DataMember]        
    public string MSISDN;

    [DataMember]        
    public string RoutingLabel;

    [DataMember]
    public string RouteAction;
}   

AppFabric memory usage once data is loaded(put): AppFabric memory usage once data is loaded(put)

2条回答
冷血范
2楼-- · 2020-04-21 03:02

I would like to answer my own question for any future users who read this.

Do not use AppFabric rather look at products like Redis or MemCached. They are better in every way that I can see.

AppFabric still has way too many problems for it to be in my production systems.

查看更多
狗以群分
3楼-- · 2020-04-21 03:17

If you're using AppFabric 1.1, you need to know that it's internal GC doesn't release any memory allocated. So if you're certain of the amount of memory you want to use OR have LRU enabled, you can limit the memory for the CacheCluster Host (e.g. SET-CacheHostConfig -HostName ServerName -CachePort PORT -CacheSize 1024). This will ensure your memory usage is not ABOVE that level. It is important to understand that it will creep UP TO that level inevitably.

查看更多
登录 后发表回答