0

我正在爲我們的Web角色羣集使用Azure的角色內緩存。多個DataCacheClients - 奇怪的配置行爲

我需要使用單獨的dataCacheClients以便具有不同且明確設置的傳輸屬性配置(maxBufferPoolSizemaxBufferSize)。

問題是每個dataCacheClient始終設置爲相同的maxBufferPoolSizemaxBufferSize值。它們都被設置爲我首先實例化的dataCacheFactory的值。 (載靜態「經理」內部)

<dataCacheClients> 
    <dataCacheClient name="DataCache1"> 
    <autoDiscover isEnabled="true" identifier="MyRoleName" /> 
    <transportProperties maxBufferPoolSize="6400000" maxBufferSize="256" /> 
    </dataCacheClient> 
    <dataCacheClient name="DataCache2"> 
    <autoDiscover isEnabled="true" identifier="MyRoleName" /> 
    <transportProperties maxBufferPoolSize="0" maxBufferSize="10485760" /> 
    </dataCacheClient> 
    <dataCacheClient name="DataCache3"> 
    <autoDiscover isEnabled="true" identifier="MyRoleName" /> 
    <transportProperties maxBufferPoolSize="3276800" maxBufferSize="32768" /> 
    </dataCacheClient> 
</dataCacheClients> 

每個混凝土DataCache對象是從單獨的DataCacheFactory實例實例化。我也嘗試恢復以編程方式創建緩存客戶端,但無濟於事。

所以,這裏是一個例外,在256

DataCacheException thrown

被拋出由於MAXBUFFERSIZE太小調試時工廠,你可以清楚地看到,MAXBUFFERSIZE不是256:

MaxBufferSize debugging

我開始拉我的頭髮了,所以我想出了兩個想法:

我的猜測是,每個數據客戶端的AutoDiscoveryProperties中的StartPortDiscoveryPort都是相同的(22233與StartPort和24233與DiscoveryPort相同),這使我相信他們可能從同一工廠拉出(並因此使用相同的工具設置)。

另外,每個客戶端的DataCacheServerEndpoint也是相同的,在20004.也許他們需要有所不同?

我正在使用Microsoft.WindowsAzure.Caching 2.4.0.0和Azure SDK 2.4。

任何人都可以幫助我指出正確的方向嗎?

回答

-1

嘗試使用下面的代碼片段:

 // DataCacheFactoryConfiguration encapsulates the datacache client section of the config. 
     DataCacheFactoryConfiguration dcfc1 = new DataCacheFactoryConfiguration("DataCache1"); 
     DataCacheFactory dcf1 = new DataCacheFactory(dcfc1); 
     DataCache dc1 = dcf1.GetDefaultCache(); 

另外,您可以通過編程進行配置:

 // This will create an instance of DataCacheFactoryConfiguration from default datacache client in config. 
     DataCacheFactoryConfiguration dcfc = new DataCacheFactoryConfiguration(); 
     //You can then set the buffer size as you wish and create DataCacheFactory and DataCache after that. 
     dcfc.TransportProperties.MaxBufferSize = size; 
     DataCacheFactory dcf = new DataCacheFactory(dcfc); 
     DataCache dc = dcf.GetDefaultCache(); 

EDIT1:我用兩種不同的工廠創造了兩個不同的客戶端,我可以看到他們兩個具有不同的最大緩衝大小。

 DataCacheFactoryConfiguration dcfc = new DataCacheFactoryConfiguration(); 
     dcfc.TransportProperties.MaxBufferSize = 8388608; 
     DataCacheFactory dcf = new DataCacheFactory(dcfc); 
     DataCache dc = dcf.GetDefaultCache(); 

     DataCacheFactoryConfiguration dcfc1 = new DataCacheFactoryConfiguration(); 
     dcfc1.TransportProperties.MaxBufferSize = 8388; 
     DataCacheFactory dcf1 = new DataCacheFactory(dcfc1); 
     DataCache dc1 = dcf1.GetDefaultCache(); 
+0

我已經這樣做了。同樣的問題。 – davenewza 2014-10-18 05:01:24

+0

startPort,discoveryPort和dataCacheServerEndpoint都是服務器屬性(即客戶端需要連接到服務器的位置)。我嘗試使用兩個不同的工廠創建兩個不同的客戶端,我可以看到兩者的最大緩衝區大小不同。 – 2015-04-10 21:38:47

0

看來你的問題不是客戶端網站,而是服務器端。確保您的MAXBUFFERSIZE在你的服務器是正確的大小,sample configuration msdn

<?xml version="1.0" encoding="utf-8" ?> 
<configuration> 
    <!--configSections must be the FIRST element --> 
<configSections> 
    <!-- required to read the <dataCacheClient> element --> 
    <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 requestTimeout="15000" channelOpenTimeout="3000" maxConnectionsToServer="1"> 
     <localCache isEnabled="true" sync="TimeoutBased" ttlValue="300" objectCount="10000"/> 
     <clientNotification pollInterval="300" maxQueueLength="10000"/> 
     <hosts> 
     <host name="CacheServer1" cachePort="22233"/> 
     <host name="CacheServer2" cachePort="22233"/> 
     </hosts> 
     <securityProperties mode="Transport" protectionLevel="EncryptAndSign" /> 
     <transportProperties connectionBufferSize="131072" maxBufferPoolSize="268435456" 
          maxBufferSize="8388608" maxOutputDelay="2" channelInitializationTimeout="60000" 
          receiveTimeout="600000"/> 
    </dataCacheClient> 
</configuration> 

Azure host configuration

+0

我該如何檢查Azure In-Role緩存? – davenewza 2014-10-20 09:59:01

+0

http://msdn.microsoft.com/en-us/library/ee790928.aspx – Peter 2014-10-20 10:03:07

+0

我仍然不確定這是否適用於Azure。我在角色實例上搜索了「DistributedCacheService.exe.config」文件,但沒有發現任何內容。 – davenewza 2014-10-20 14:58:29