因此,我面临这样一种情况,即部署在 Azure 云上的项目大部分时间都获得高 CPU,但在重新启动应用程序后,CPU 使用率会在几个小时内达到 10-15%。我确实尝试使用 Kudu 分析器,但它没有帮助,大多数时候它显示某些方法在总 CPU 使用率为 100% 时使用 40% CPU,但当 CPU 使用率较低时它们为 2-3%。我注意到一个奇怪的事情是一些 API 控制器方法如果他们没有得到正确的请求 BODY 抛出 CGI/502 错误,即使它应该抛出 Null 引用异常,因为方法得到错误的主体,更有趣 - 返回 CGI异常大约需要 > 2 分钟,而不是通常在本地计算机上的 Web 服务上的 2 秒。我从 S1 计划到 S2 计划,同样的东西,尽管工作速度更快,但天蓝色的洞察力显示相同的 90-10% 的 CPU 使用率。
1 回答
0
首先,我建议您编写代码来获取服务器的故障转储,您可以参考此链接进行设置。
像下面这样的东西可以帮助你在 powershell 中编写它。
$dumpFolder = "C:\crash-dumps"
if (!(Test-Path $dumpFolder)) {
mkdir $dumpFolder | Out-Null
}
$dumpKey = "HKLM:SOFTWARE\Microsoft\Windows\Windows Error Reporting\LocalDumps"
if (!(Test-Path $dumpKey)) {
New-Item -Path $dumpKey | Out-Null
}
$dumpKey = "HKLM:SOFTWARE\Microsoft\Windows\Windows Error Reporting\LocalDumps\dotnet.exe"
New-Item -Path $dumpKey -Force | Out-Null
New-ItemProperty -Path $dumpKey -Name DumpFolder -Value $dumpFolder -PropertyType String -Force | Out-Null
New-ItemProperty -Path $dumpKey -Name DumpCount -Value 3 -PropertyType DWORD -Force | Out-Null
New-ItemProperty -Path $dumpKey -Name DumpType -Value 2 -PropertyType DWORD -Force | Out-Null
$dumpKey = "HKLM:SOFTWARE\Microsoft\Windows\Windows Error Reporting\LocalDumps\w3wp.exe"
New-Item -Path $dumpKey -Force | Out-Null
New-ItemProperty -Path $dumpKey -Name DumpFolder -Value $dumpFolder -PropertyType String -Force | Out-Null
New-ItemProperty -Path $dumpKey -Name DumpCount -Value 3 -PropertyType DWORD -Force | Out-Null
New-ItemProperty -Path $dumpKey -Name DumpType -Value 2 -PropertyType DWORD -Force | Out-Null
根据故障转储,我们可以轻松了解导致问题的部分。
对于类似的问题,您可以跟踪此请求。还尝试将您的应用程序降级到 V2.0.0 并查看它是否仍然导致 CPU 峰值。如果是,那么我们需要查看您在评论中提到的代码。
于 2019-06-25T05:35:24.843 回答