จำกัด CPU usage (Windows) ด้วยโปรแกรม ThreadMaster

เคยบ้างไหม ที่เครื่องเรา process โปรแกรมหนึ่ง จนไม่เหลือให้โปรแกรมอื่น ซ้ำร้ายบางทียังถึงขนาดแฮ้งไปเลย

คงไม่ดีแน่ ถ้าหาก server ของเราทำงานจนไม่มี process เหลือให้ service อื่นๆบ้าง หรือร้ายกว่านั้น อาจ down ไปเลยก็เป็นได้

แน่นอนว่าการใส่แรมเยอะๆ อาจช่วยได้พอสมควร แต่ถ้า process หนักๆ ยาวๆล่ะ อย่างนี้คงไม่ต้องทำงานอย่างอื่นกันพอดี

วันนี้เรามีวิธีแก้ไขกันแล้ว โปรแกรม Thread Master ช่วยท่านได้ huhu.png

แหะๆๆ พูดซะเหมือนโฆษณาเลยแฮะ...
ก็ไม่มีอะไรมากหรอกครับพอดีเนื่องจากผมต้องทำการ shrink ลอร์ด จาก DVD9 - DVD5 บนเครื่อง server
ซึ่งต้องเหลือ process ไว้ให้ Azu, FTP, HTTP, Proxy และ service ลูกค้าด้วย emo1170.gif
ซ้ำร้าย เครื่องผมยังอยู่หลังตู้ซีลนรก ซึ่งร้อนมากๆ process 100% ไม่ถึงห้านาทีก็ทำให้อุณหภูมิ cpu สูงเกิน 75 องศาเลย zaD.png
ว่างั้นก็เลยเที่ยวควานหาวิธีที่จะ limit process ของ cpu เพื่อไม่ให้ server มันตายไปเสียก่อน
แล้วก็ได้ความช่วยเหลือจาก admin ที่น่ารักคนหนึ่ง (ผู้ไม่ประสงค์จะออกนาม แต่ใครๆก็รู้ดีว่าเป็นใคร bla bla.gif )
ช่วยกันหาจนได้โปรแกรมตัวนี้มาให้ลองใช้ดู ปรากฏว่าผลที่ได้มันยอดมาก เลยเอามาแนะนำให้คนที่ต้องการนำไปใช้กันดู

โปรแกรมนี้ชื่อว่า Thread Master ครับ การทำงานคร่าวๆของมันก็คือตรวจจับ process ที่เกินค่าที่เราตั้งไว้ แล้วลด process ลงมาตามที่ตั้งเอาไว้
ซึ่งเป็นการ limit process ของแต่ละโปรแกรม ไม่ใช่ overall นะครับ มีความยืดหยุ่นดี สามารถตั้ง process ให้แต่ละ priority ได้ด้วย

คำอธิบายของเค้าครับ

QUOTE
ThreadMaster
ThreadMaster Monitors Threads and handle high CPU utilization on a per application basis.
This function is primarily indented for Terminal servers hosting multiple users. 
ThreadMaster can also be used when running multiple virtual machines on the same server, to limit each  virtual machines CPU usage.

ThreadMaster is a background service implementing a CPU Quota mechanism on top of the standard thread scheduling algorithms of the Microsoft Windows 2000 Operating Systems.

A single user is capable of hogging all of the processor resources. The result will be a reduction in the quality of service experienced by all other users on the server. ThreadMaster can help you to deal whit this situation.

ThreadMaster monitors all running applications, and detects when a application  starts to  use excessive processor resources. It dynamically hunt down the offending thread, and clamp the CPU for this thread. This feature ensures that other users can remain working without noticing anything. The clamped process will eventually finish, and the clamp will be removed automatically.

Remember: 20 applications, each having a CPU utilization of 5 % still adds  up to 100%.

Administration of ThreadMaster is extremely simple, the behavior is in general, controlled by only two key parameters.
The first parameter instructs ThreadMaster to monitor application activity over a given of  time.
The second parameter is the allowed max. average CPU utilization for the process over the defined  time.

เอาละ เรามาดูการทำงานคร่าวๆกันดีกว่า

ขั้นตอนการติดตั้งผมไม่เอารูปให้ดูนะครับ แค่แตก file แล้วกด install เท่านั้น

โปรแกรมนี้เป็น non GUI นะครับ การแก้ไขค่าต่างๆ ต้องแก้ที่ registry ของโปรแกรมนี้
ค่าที่จะเซ็ต จะอยู่ใน sub parameter ซึ่งมีให้แก้สองค่า คือ cpu process (ของแต่ละโปรแกรม) และ sample time (detect cycle)
ส่วนการตั้งค่าของแต่ละ priority สามารถดูตัวอย่างการเซ็ตได้จาก readme นะครับ

ส่วนนี้เป็นการเก็บ log ของโปรแกรมที่ใช้ process เกิน

หลังจากเซ็ตค่าเสร็จแล้ว ก็เข้ามาที่ service แล้วสั่ง restart ทีนึง (ต้องทำทุกครั้งที่มีการเปลี่ยนค่าต่างๆ ไม่งั้นมันจะไม่เปลี่ยนนะครับ)

จากรูปจะเห็นว่า process จะวิ่ง 100% พักนึง (ราวๆ 30 วินาที ตามที่ตั้งไว้) พอมันเจอ มันก็จะเริ่มทำการลด process ลงมาครับ
จากกราฟจะเห็นว่า ลด process ลงมาเหลือราวๆ 40% ตอนนี้ยังใช้ค่าเดิมที่ตั้งไว้ (program ละ 15%)ซึ่งผมสั่งให้ server ทำงานดังนี้ครับ
1. Azureus เปิดโหลดพร้อมกั้น 6 torrent
2. Azureus สร้าง torrent file ของ ลอร์ด ภาคแรก ขนาด 9GB
3. DVD Shrink ลอร์ด ภาคสอง
อุณหภูมิ CPU ก็ไม่เกิน 70 อีกด้วย ช่วยผมได้เยอะจริงๆ think.gif

จากที่ทำงานทั้งสามอย่างข้างบน ยังมี ftp ที่บ้านกลับไปอีก และลูกค้าที่ใช้ HTTP, FTP และ Proxy อีกด้วย 038.gif

เอาไปลองใช้ดูละกัน website ผู้ผลิตครับ

 
Cradit : Wind_walker from the web you know where