0
votes

In an ASP.NET MVC application I'm performing calculations which are in an xlsx file. We are talking about 18K variables in the calculations (xlsx file is around 10MB), so loading them them into a SpreadSheetGear instance takes a while. Therefore I need to cache the SpreadSheetGear object in between requests otherwise each request would take forever.

Right now I'm using In-Proc Application Cache and Session Cache to save the data between requests. In my test environment the Application Pool of the IIS recycles way sooner (sometimes just a few minutes) than our session timeout (I think the default 20 minutes). The Pool recycle causes the loss of all In-Proc cached data, and the lengthy load procedure has to happen again.

  1. As far as I can see there's no function to serialize the SpreadSheetGear object (other than to save it in xlsx format for example). If I could serialize it, then I could maybe switch over to an out of process caching vehicle. But even then I'm a little skeptic how that would perform compared to the In-Proc memory cache.
  2. I couldn't figure out why the recycle happens. The server is memory starved though, but I don't have any memory limit or VM memory limit set for the IIS App Pool. I don't find the recycling events in the IIS log.
  3. Is there any way to shelter that In-Proc memory data to survive an App Pool recycling?

Does anyone have similar experience with SpreadSheetGear + ASP.NET MVC + IIS?

1
So far what we'll try to do is go with Azure VMs, where I can start the State Server. VMs can scale out too (with some limitations: pre-provisioned from an availability group) and if I can nicely shim the non-round-robin, ARR aware load balancer, then I'll be goldenCsaba Toth
Out of proc State Server doesn't help either, that requires serialization too. We are on our own hoping the best so IIS doesn't decide to recycleCsaba Toth

1 Answers

0
votes

I had similar problem, when multiple sessions were taking too much memory. Once threshold reached IIS terminated random sessions to free memory. The solution was to change caching from CacheItemPriority.Default to CacheItemPriority.NotRemovable. That way IIS wont remove sessions from memory and on timeout or if session closes it will call CacheItemRemovedCallback() and remove from memory.

HttpRuntime.Cache.Insert(workbookPath, myWorkbook, Nothing, Cache.NoAbsoluteExpiration, New TimeSpan(0, 0, 1520), CacheItemPriority.NotRemovable, New CacheItemRemovedCallback(AddressOf OnRemoveCallBack))