php CPU usage problem

General Tech Bugs & Fixes 2 years ago

0 2 0 0 0 tuteeHUB earn credit +10 pts

5 Star Rating 1 Rating

Posted on 16 Aug 2022, this text provides information on Bugs & Fixes related to General Tech. Please note that while accuracy is prioritized, the data presented might not be entirely correct or up-to-date. This information is offered for general knowledge and informational purposes only, and should not be considered as a substitute for professional advice.

Take Quiz To Earn Credits!

Turn Your Knowledge into Earnings.

tuteehub_quiz

Answers (2)

Post Answer
profilepic.png
manpreet Tuteehub forum best answer Best Answer 2 years ago

 

I'm using a php script that use alot of php and mysql queries installed in dedi with 4 cores and 16gb ram when i use the command top it shows that php consume 80% of CPU however using the command mpstat - ALL to find out usage per core it show different result 96% idle for every core

root@datax:~# top   
PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND
27629 root      20   0  287432  31336  18544 R  80.1  0.2   0:19.20 php
1006 mysql     20   0 2400692 100236  11340 S  21.3  0.6 220:35.64 mysqld



root@datax:~# mpstat -P ALL
Linux 3.16.0-4-amd64 (datax)    07/31/2016      _x86_64_        (4 CPU)

05:03:13 AM  CPU    %usr   %nice    %sys %iowait    %irq   %soft  %steal  %guest  %gnice   %idle
05:03:13 AM  all    1.39    0.15    0.51    1.72    0.00    0.03    0.00    0.00    0.00   96.19
05:03:13 AM    0    1.31    0.15    0.47    1.73    0.00    0.03    0.00    0.00    0.00   96.31
05:03:13 AM    1    1.33    0.15    0.48    1.76    0.00    0.03    0.00    0.00    0.00   96.25
05:03:13 AM    2    1.49    0.15    0.55    1.68    0.00    0.03    0.00    0.00    0.00   96.10
05:03:13 AM    3    1.44    0.14    0.55    1.72    0.00    0.03    0.00    0.00    0.00   96.11
profilepic.png
manpreet 2 years ago

The mpstat output is showing you the averages since boot (not "now") when you run it without an interval setting. You can adjust your call to:

root@datax:~# mpstat -P ALL 1

this should provide you more of the 'now' information


0 views   0 shares

No matter what stage you're at in your education or career, TuteeHub will help you reach the next level that you're aiming for. Simply,Choose a subject/topic and get started in self-paced practice sessions to improve your knowledge and scores.