Powershell limits the CPU similarity of processes (set affinity)

Source: Internet
Author: User

The CPU usage of the site has been monitored in the last two days. If you want to restrict the site to a maximum of three cores on a 4-core server, you can set the maximum CPU usage of the site to 75%;

(1) Use scheduled tasks to regularly execute the following powershell scripts;

<# Script's function: Set affinity of w3wp.exe to cpu1, cpu2, cpu3 Script Editor: snil Date: 2014-08-08 refer to website: http://technet.microsoft.com/zh-cn/subscriptions/index/system.diagnostics.process.processoraffinity http://waynes-world-it.blogspot.com/2009/06/processor-affinity-on-windows-server.html #> $ w3wps = Get-process-processname "w3wp" foreach ($ w3wp in $ w3wps) {$ w3wp. processoraffinity = 0x0e}

For an explanation of "0x0e", refer to: http://technet.microsoft.com/zh-cn/subscriptions/index/system.diagnostics.process.processoraffinity

 

(2) manual operation designation; (this method is time-sensitive and requires manual operation once a day, which is temporary ;)

1. Open the resource manager and find the site to be qualified. Right-click and select "set affinity ..."

650) This. width = 650; "style =" border-bottom: 0px; border-left: 0px; border-top: 0px; border-Right: 0px; "Title =" image "border =" 0 "alt =" image "src =" http://img1.51cto.com/attachment/201408/8/907015_1407467656UFTo.png "Height =" 149 "/>

2. Check the specified CPU and click OK;

650) This. width = 650; "style =" border-bottom: 0px; border-left: 0px; border-top: 0px; border-Right: 0px; "Title =" image "border =" 0 "alt =" image "src =" http://img1.51cto.com/attachment/201408/8/907015_1407467657aRCk.png "Height =" 244 "/>

 

(3) Use wsrm limitation. (This function is not recommended. The wsrm function has been canceled after server 2012 and is replaced by some hyper-V functions)


This article from the "fate with wishes" blog, please be sure to keep this source http://281816327.blog.51cto.com/907015/1537320

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.