Caching large objects - LocalCache performance
Asked Answered
H

1

0

I have a few large objects which need to be stored and fetched from cache. These objects are around 1 - 2 mb in size.

When running with localCache enabled, retrieval takes no more than a few milliseconds, but without it, it takes around 3 seconds, consistently.

I am using Azure In-role cache (colocated).

Can anyone shed some light as to why it would be so much slower without localCache enabled?

Hipster answered 17/10, 2014 at 15:18 Comment(1)
Probably more on topic at SO as this is more of an implementation issue question.Kowalewski
C
1

LocalCache is local to the process, i.e. within the application's process memory. If LocalCache is enabled, object fetched from cache will also be stored in LocalCache. Every next request for that object will be served from that LocalCache (No need to fetch from out of process cache). However retrieving object for the first time will take time.

According to MSDN:

When local cache is enabled, the cache client stores a reference to the object locally. This keeps the object active in the memory of the client application. When the application requests the object, the cache client first checks whether the object resides in the local cache. If so, the reference to the object is returned immediately without contacting the server. If it does not exist, the object is retrieved from the server. The cache client then deserializes the object and stores the reference to this newly retrieved object in the local cache. The client application uses this same object.

Whereas when local cache is disabled, every retrieval request is directed to out-proc cache, resulting in fetching object from outside process's memory every time.

Clubman answered 20/10, 2014 at 19:7 Comment(2)
Thanks for the answer but surely 3 seconds is still excessive? I know that 1 - 2mb is very large, but the cache is colocated, so I really cant undetstand what would take so long?Hipster
You can try other solutions like NCache for Azure to benchmark your application's performance. Since it may be some performance issue with Azure in-role cache.Clubman

© 2022 - 2024 — McMap. All rights reserved.