How much does using a processor cost on a linux server

I am running several PHP jobs that retrieve 100,000 data from a web service and paste it into a database. These jobs take up processor utilization of the server.

My question is how tall is it?

When I make the "top" command on linux server, it seems like 77%. It will increase to more than 100% if I run more tasks at the same time. It seems to me that this is very important (more than 100% means that it works on the second processor?)

28908 mysql 15 0 152m 43m 5556 S 77.6 4.3 2099: 25 mysqld             
 7227 apache 15 0 104m 79m 5964 S 2.3 7.8 4: 54.81 httpd 

This server also has web pages / projects hosted on it. Hourly work, as it affects the server, as well as the loading time of another web project.

If tall, is there a way to make it more efficient on the processor?

Can anyone enlighten?

+3
source share
5 answers

The best indicator is the average load level , if I simplify, this is the number of pending tasks due to lack of resources.

You can access it as a team uptime, for example 13:05:31 up 6 days, 22:54, 5 users, load average: 0.01, 0.04, 0.06. The 3 numbers at the end are the average load values ​​for the last minute, last 5 minutes and last 15 minutes. If he reaches 1.00, (regardless of the number of cores), this is what he is waiting for.

+1
source

, 77% .

, , ( ), .

script nice cmd, , .

, , , .

, /

0

. : ?

. 100% . ? , , , .

0
source

Nice will not help, since it is mysql occupying your processor, putting a good one on the php client, as in

nice -10 php /home/me/myjob.php

will not have significant differences.

It’s better to split the work into smaller parts, name the php-script from cron and build it like

<?
ini_set("max_execution_time", "600")
//
//1. get the file from remote server, in chunks to avoid net saturation
$fp = fopen('http://example.org/list.txt');
$fp2 = fopen('local.txt','w');
while(!feof($fp)) {
  fwrite($fp2,fread($fp,10000));
  sleep(5);
}
fclose($fp/fp2);

while(!eof(file) {
  //read 1000 lines
  //do insert..
  sleep(10);
}
//finished, now rename to .bak, log success or whatever...
0
source

Source: https://habr.com/ru/post/1783827/


All Articles