我正在使用 HttpRuntime.Cache
在 Azure 上进行内存缓存。
问题是内存已满 - 然后它达到了 Azure 90% 的百分比限制,Azure 认为该角色不健康并重新启动它 - 导致整个站点瘫痪。
现在我找到了 EffectivePercentagePhysicalMemoryLimit 属性,它在 Azure 上似乎设置为 98%,因此高于 90% 的“不健康”限制。
- 如何更改
HttpRuntime.Cache
的此限制?该属性是只读的。 - 是否可以将 Azure 自动重启百分比调整得更高一点?
- 对于使用内存缓存还有其他推荐设置吗?我还应该使用其他类(class)吗?我能找到的与Azure结合的信息很少。如果数据需要在多个实例之间保持一致,大多数文章都会讨论单独的缓存服务。
需要明确的是:我想要内存缓存 - 我不需要通过 Redis 进行共享缓存,因为数据不太需要保持一致。
最佳答案
您可以使用 cache
Element 的 percentagePhysicalMemoryUsedLimit
属性更改 EffectivePercentagePhysicalMemoryLimit
在你的 web.config 中
<configuration>
<system.web>
<caching>
<cache percentagePhysicalMemoryUsedLimit="60" />
</caching>
</system.web>
The
EffectivePercentagePhysicalMemoryLimit
property can be set with thepercentagePhysicalMemoryUsedLimit
attribute of thecache
Element for caching (ASP.NET Settings Schema) element in the application's configuration file. If thepercentagePhysicalMemoryUsedLimit
attribute is not set, the cache algorithm determines the maximum size of the cache, and theEffectivePercentagePhysicalMemoryLimit
property is calculated.
您可以在文档中获取更多信息:Cache.EffectivePercentagePhysicalLimit
<小时/>另一个选项是禁用 Azure 自动重启机制。它被称为Proactive Auto Heal您可以通过将 WEBSITE_PROACTIVE_AUTOHEAL_ENABLED
设置为 False
来禁用它:
- 转至 Portal.azure.com,然后转至您想要禁用该功能的网络应用。
- 在“设置”下,转到“应用程序设置”。
- 在“应用设置”下添加“
WEBSITE_PROACTIVE_AUTOHEAL_ENABLED
”并将其设置为“False
”。 - 就是这样!主动自动修复已禁用。
关于asp.net - Azure 的 HttpRuntime.Cache 设置?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46941877/