3
votes

I am trying to set cpu rate limit i was able to perform this action in UI using the action link

https://theitbros.com/set-cpu-usage-limit-for-an-application-pool-iis-8/

but i want to set three values below using powershell

CPU limit=20%
CPU limit Action= Killw3p
Cpu Limit Interval= 1

Iam already using powershell to setup startmode to always running.

set-itemproperty IIS:\AppPools\AddressBroker.API -name startMode -value AlwaysRunning

I have tried something like below but does not work.

set-itemproperty IIS:\AppPools\AddressBroker.API -name CPU -value Limit=20%
3

3 Answers

2
votes

I figured out the correct command that works for me is below.

C:\windows\system32\inetsrv\appcmd.exe set apppool AppPOOLName /cpu.limit:20000 /cpu.action:KillW3wp /cpu.resetInterval:00:01:00
1
votes

According to your description, I suggest you could try to use below command to acheive your requirement.

C:\windows\system32\inetsrv\appcmd.exe set apppool /cpu.limit:20000 /cpu.action:KillW3wp /cpu.resetInterval:00:01:00

Result:

enter image description here

0
votes

If you're looking for the PowerShell solution, you'll need to correct the property name:

Import-Module WebAdministration
$appPool = Get-Item IIS:\AppPools\AddressBroker.API
$appPool | Set-ItemProperty -name "cpu.limit" -value 20000
$appPool | Set-ItemProperty -name "cpu.action" -value "ThrottleUnderLoad"
$appPool | Set-ItemProperty -name "startMode" -value "AlwaysRunning"