I'm using HttpRuntime.Cache for memory caching on Azure.
The problem is that the memory goes full - then it hits the 90% percentage limit of Azure, Azure thinks the role is unhealthy and restarts it - bringing the whole site down.
Now I found the EffectivePercentagePhysicalMemoryLimit property and it seems to be set to 98% on Azure, so above the 90% 'unhealthy' limit.
HttpRuntime.Cache? The property is readonly.To be clear: I want memory caching - I don't need a shared caching through i.e. Redis, because the data has not a great need to be consistent.
You can change the EffectivePercentagePhysicalMemoryLimit by using the percentagePhysicalMemoryUsedLimit attribute of the cache Element in your web.config
<configuration>
<system.web>
<caching>
<cache percentagePhysicalMemoryUsedLimit="60" />
</caching>
</system.web>
The
EffectivePercentagePhysicalMemoryLimitproperty can be set with thepercentagePhysicalMemoryUsedLimitattribute of thecacheElement for caching (ASP.NET Settings Schema) element in the application's configuration file. If thepercentagePhysicalMemoryUsedLimitattribute is not set, the cache algorithm determines the maximum size of the cache, and theEffectivePercentagePhysicalMemoryLimitproperty is calculated.
You can get more information on the documentation : Cache.EffectivePercentagePhysicalLimit
The other option is to disable the Azure auto restart mechanism. It is called Proactive Auto Heal and you can disable it by setting the WEBSITE_PROACTIVE_AUTOHEAL_ENABLED to False :
WEBSITE_PROACTIVE_AUTOHEAL_ENABLED” and set it to “False”.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With