azure asp.net core 2.2获得高cpu使用率

6gpjuf90  于 2021-06-24  发布在  Kudu
关注(0)|答案(1)|浏览(415)

因此,我面临这样一种情况:部署在azure云上的项目在大多数情况下cpu使用率都很高(100%),但重新启动应用程序后,cpu使用率会在几个小时内达到10-15%。我确实尝试过使用kudu profiler,但是没有用,大多数情况下,它显示一些方法在总cpu使用率为100%时使用了40%的cpu,但在cpu使用率较低时使用率为2-3%。我注意到的一件奇怪的事情是,一些api控制器方法如果没有得到正确的请求主体抛出cgi/502错误,即使它应该是抛出空引用异常,因为该方法得到了错误的主体,更有趣的是-返回cgi异常需要约2分钟,而不是像通常在本地计算机上的web服务上那样2秒。我从s1到s2计划,同样的东西,虽然工作速度快了一点,但azureinsights显示相同的90-10%的cpu使用率。

1dkrff03

1dkrff031#

首先,我建议您编写一个代码来获取服务器的崩溃转储,您可以参考此链接进行设置。
下面的内容将帮助您在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峰值。如果是的话,我们需要看看你的代码中提到的评论。

相关问题