Domanda

I'm trying to put an object which is ~60MB into a single cache item however I am constantly greeted with the following error

ErrorCode<ERRCA0016>:SubStatus<ES0001>:The connection was terminated, possibly due to server or network problems or serialized Object size is greater than MaxBufferSize on server. Result of the request is unknown.. Additional Information : The client was trying to communicate with the server: net.tcp://127.255.0.0:20004/.

At first the error indicated a specific size and it was clear that the client couldn't send such a large message so I increased the MaxBufferSize in the client using the folliwing

<transportProperties maxBufferSize="999999999"/>

Googling and SO searches provided limit resources regarding configuration of the Cache Role (most results prompted the change of the web.config of the web role or similar) Even Microsoft's documentation is limited.

Is it possible, and if so how, to increase the maximum size of a message that a cache role can cache?

È stato utile?

Soluzione 4

The maximum size of a single object that can be cached is 8 MB, after being serialized. There is no way to get the cache library to Put a greater sized object into the cache.

What you can try and do instead is split the object in your client into multiple (in this case 6) objects, but that is really messy.

If you really can not live with the 8 MB restriction, you should put in a feature request here.

Altri suggerimenti

You only changed the Cache client config setting. Probably in your app.config/web.config under:

<dataCacheClients>
  <dataCacheClient name="default">
    <transportProperties maxBufferSize="XXXXX" />
  </dataCacheClient>
</dataCacheClients>

Now the cache client is allowing the call but the server is failing it. You also need to set the maxBufferSize for the server. To do this

  1. Right click your role
  2. Add -> New Item -> XML File
  3. Name it "CacheSettings.xml"
  4. Paste the following XML:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
 <configSections>
   <section name="dataCache" type="Microsoft.ApplicationServer.Caching.DataCacheSection, Microsoft.ApplicationServer.Caching.Core" allowLocation="true" allowDefinition="Everywhere" />
 </configSections>
 <dataCache size="Small">
   <advancedProperties>
     <transportProperties maxBufferSize="XXXX" maxBufferPoolSize="XXXX" />
   </advancedProperties>
 </dataCache>
</configuration>

There seem to have been issues with cache since about 5 July 2013. On one application we set the buffer size, which fixed the problem, but on another application it didn't help. The errors seem to be transient though. Although it doesn't exactly solve the problem, retries will stop application falling over. We put code similar to the listing below to temporarily wallpaper over the problems we were experiencing.

try
{
    _cache.Value.Put("key", obj);
}
catch (DataCacheException e)
{
    if (e.ErrorCode == 17)
    {
        Thread.Sleep(250);
        _cache.Value.Put("key", obj);
    }
    else
    {
        throw;
    }
}

The above checks for error 17, but 16 should be similar. You will also want to log when you are doing this so that you don't forget that there is still a problem.

The max size of object is 8 MB as Abhinav mentioned earlier. Cache is meant for quickly accessing small frequently used objects. If you really need to store large objects and use them quickly, you should be considering table storage instead. It's the closest you'll get to Cache in terms of performance.

Alternatively, store your data in different pieces and create a singleton / static facade interface which can provide you with individual components or construct a concrete object and return it as per requirement.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top