AppFabric caching the local cache does not work for us ... What are we doing wrong?

We use appfabric as the second level cache for the NHibernate asp.net application, which includes the client website and the admin website. They are both connected to the same cache, so when the administrator updates something, the client site is updated.

It seems to be working fine - we have CacheCLuster on a separate server, and everything is fine, but we want the local cache to get better performance, however it seems to work.

We turned it on like that ...

bool UseLocalCache = int LocalCacheObjectCount = int.MaxValue; TimeSpan LocalCacheDefaultTimeout = TimeSpan.FromMinutes(3); DataCacheLocalCacheInvalidationPolicy LocalCacheInvalidationPolicy = DataCacheLocalCacheInvalidationPolicy.TimeoutBased; if (UseLocalCache) { configuration.LocalCacheProperties = new DataCacheLocalCacheProperties( LocalCacheObjectCount, LocalCacheDefaultTimeout, LocalCacheInvalidationPolicy ); // configuration.NotificationProperties = new DataCacheNotificationProperties(500, TimeSpan.FromSeconds(300)); } 

First, we tried to use a timeout cancellation policy (3 minutes), and our application felt that it was running faster. HOWEVER, we noticed that if we changed something on the admin site, it was immediately updated on the site. Since we use timeouts without notifications, this demonstrates that the local cache is not requested (or is, but always absent).

Cache .GetType (). The name returns "LocalCache" - so the factory made a local cache.

Running Get-Cache-Statistics MyCache on PS in my dev environment (an asp.net application running locally with vs2008, a cache cluster running on a separate w2k8 machine) shows several requests. However, in a production environment, the number of requests increases dramatically.

We tried to execute the method here to pass the cache traffic of the cliebt server ... http://blogs.msdn.com/b/appfabriccat/archive/2010/09/20/appfabric-cache-peeking-into-client-amp- server-wcf-communication.aspx , but there was nothing in the log file except the initial header in it - that is, not a login.

I can not find anything in SO or Google.

Did we do something wrong? We have an AppFabric screw installation - we installed it through the WebPlatform Installer - I think? (note: the IIS box that works with ASp.net is not in the cluster - it's just a client).

Any ideas received with thanks!

+4
source share
3 answers

What DataCache methods DataCache you use to read from the cache? Some of the DataCache methods DataCache always hit the server regardless of whether the local cache is configured. You should almost certainly be sure to use only Get if you want the local cache to be enabled.

This is one of my biggest nits with AppFabric Caching. They donโ€™t explain anything to you, and so when you start relying on local caching, you start falling into these small traps because you donโ€™t think you pay a fine for talking to the service, transferring data over the wire and deserializing objects, but you.

The worst part is that I could understand that I needed to talk to the service to make sure that the local cache represents the latest data. I even understand that transferring data back so that several calls are not made. What I cannot understand because of my life is that even if the instance in the local cache is checked to be the current version returned from the cache, they still deserialize the object from and not just return the instance that is already in memory . If your objects are large / complex, this can be very damaging.

+1
source

After days and days when we figure out why we get so many local cache passes, we finally decided:

  • AppFabric v 1.1 has an error with a local cache, which is fixed in CU4, see http://support2.microsoft.com/kb/2800726/en-us
  • Verify that the Microsoft.ApplicationServer.Caching.Client.dll file used by your application is also updated. We had CU4 installed on the machine, but Client.dll without CU4 from the NuGet package was delivered in our application. In our case, a simple update to the NuGet package made everything work.

After installing CU4 and verifying that Client.dll was also updated, we significantly reduced our readings in AppFabric Host due to the increase in the number of local caches. yay!

+1
source

Have you tried using the nhibernate profiler? http://nhprof.com/

There is also the following: http://mdcadmintool.codeplex.com/

This is a good way to manage and view the cache.

Both options can help in debugging the problem.

0
source

Source: https://habr.com/ru/post/1334964/


All Articles