问题:我做错了吗?配置设置不正确?AppFabric 显示的内存使用量是否正常?
问题:我正在将 SQL 数据库表中的数据读取到 AppFabric 缓存中。似乎 AppFabric 为一个相当小的对象使用了大量内存,我不明白为什么(我最近开始使用 ApppFabric,所以我是个菜鸟)
说明:大约 60MB 的 SQL 表在 AppFabric 缓存中转换为大约 800MB 一次。
细节:
我打算加载的表的 SQL 数据大小:
App Fabric 空闲内存使用情况:
服务器配置:
<?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>
客户端配置:
<?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>
C# 代码:
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 内存使用情况: