Azure 应用服务可用性损失。内存计数器 Page Reads/sec 处于危险级别

Azure app service availability loss. The memory counter Page Reads/sec was at a dangerous level

环境: Asp Net MVC 应用程序(.net framework 4.5.1)托管在具有两个实例的 Azure 应用程序服务上。 应用程序使用 Azure SQL 服务器数据库。 此外,应用程序使用 MemoryCache (System.Runtime.Caching) 进行缓存。

最近,我注意到该应用程序的可用性下降。它几乎每天都在发生。

观察: 实例 RD0003FF1F6B1B 上的内存计数器 Page Reads/sec 处于危险级别 (242)。任何超过 200 的值都可能导致该实例上任何应用的延迟或失败。

'The memory counter Page Reads/sec' 是什么意思? 如何解决这个问题?

What 'The memory counter Page Reads/sec' means?

我们可以从这个blog中得到答案。推荐的 Page reads/sec 值应低于 90。较高的值表示 内存不足 索引问题

“Page reads/sec indicates the number of physical database page reads that are issued per second. This statistic displays the total number of physical page reads across all databases. Because physical I/O is expensive, you may be able to minimize the cost, either by using a larger data cache, intelligent indexes, and more efficient queries, or by changing the database design.”


How to fix this issue?

根据我的经验,您可以尝试在应用程序中启用本地缓存 服务.

You enable Local Cache on a per-web-app basis by using this app setting: WEBSITE_LOCAL_CACHE_OPTION = Always

By default, the local cache size is 300 MB. This includes the /site and /siteextensions folders that are copied from the content store, as well as any locally created logs and data folders. To increase this limit, use the app setting WEBSITE_LOCAL_CACHE_SIZEINMB. You can increase the size up to 2 GB (2000 MB) per web app.

有一些内存性能问题可以列出来

  • 分页过多,
  • 内存不足,
  • 内存泄漏

内存计数器值可用于检测各种性能问题的存在。在 system-wideper-process 基础上跟踪计数器值有助于查明 Azure 中的原因,例如其他系统。

即使进程没有变化,系统的变化也会导致内存问题。 system-wide

研究蔚蓝:

共享资源计划(免费和基本)有内存限制,如下所示:https://docs.microsoft.com/en-us/azure/azure-subscription-service-limits#app-service-limits

配额https://docs.microsoft.com/en-us/azure/app-service-web/web-sites-monitor

此外,您可以在您的网络应用程序设置下查看门户,搜索“配额”,还可以查看“诊断和解决问题”并点击“每个实例的指标(应用程序服务计划)”,这将显示你的内存用于计划。

.net 4 中的 MemoryCache 错误也可能导致此类行为