M
M
mr_smith2010-12-11 23:47:46
CentOS
mr_smith, 2010-12-11 23:47:46

How to find out the server load in percent?

There are two (the number will grow in the future) servers on which the same highly loaded web project is running, the code is the same, the axis is CentOS. Servers differ in hardware, the first is 2-core with 4 gigs of RAM, the second is 4-core with 8 gigs of RAM.
At the entrance we have - a bunch of users, each of which loads the server, and in different ways - some more, some less, 10 minutes ago like this, now that's it; a new user can be added, which will create a very large load, and so on. There are statistics for all of this. The task is to distribute users among servers so that the workload of these servers is more or less the same. Since the user loads the server in different ways, then it is necessary to redistribute users across servers every 10-20 minutes.
Distribution requires server load data. You need to get them using php or the operating system as a percentage, they say the average load on server No. 1 over the last 15 minutes = 85%. PHP can be obtained using the sys_getloadavg function, however, the resulting value is "the number of processes in the system run queue", and, as I understand it, it does not have a maximum value, i.e. it is impossible to express the load in percentage terms, which is why it is impossible to determine the conditional “capacity” of each server - the maximum number of users that can be sent to a particular server. There is an option to write data from top to the log or memcache, but this will have to be done very often (every second?) In order to get the most reliable data, the load then jumps. In general, habrato comrades, your suggestions =)

Answer the question

In order to leave comments, you need to log in

7 answer(s)
R
redsh, 2010-12-12
@redsh

LA is a very good metric for assessing system load, it’s
better to use it instead of any percentages
, but if you really want to, you can somehow translate empirically into percentages
x = 100 - 100 / (LA + 1)
, for example, something like this )

K
keatis, 2010-12-12
@keatis

And how do you want to calculate the load on the server as a whole? This is not only a processor, but also a disk subsystem, a network one, any memory is virtual and not very ... If only some composite “percentage” is counted, indicating the load weights of each system.
But why, when there is a load average (LA)? Just look at his numbers and the larger they are, the more worried.

P
pentarh, 2010-12-12
@pentarh

There can be 5 server load parameters: processor, memory, disk io, free disk space and network.
Moreover, when loading at least one of them to high values, the values ​​of the rest fly into tartar. These tartars are called battlenecks or bottlenecks.
Here also consider. Proc - top, place - df, io - iostat, network - nload. It is not as easy to determine the load of the operative as with the rest. You need to look at free,buffers,cached and total. And move your brain. Signs of a lack of memory are at first an increasing load on the screw, tk. cache flies. And then the increase in the swap.
LA, although it allows you to judge the load, but only relatively. Each type of load has its own allowable bar LA. For me it varies from 1 to 50 depending on the server. In addition, it also depends on the number of virtual processors.
In general, you need to take this all into account and apply it specifically to your situation. There is no universal formula.

P
pentarh, 2010-12-12
@pentarh

By the way, there is another battleneck - context switches in vmstat. It manifests itself very rarely, with the number of processes from 2k. It seems that there is a reserve for 5 main ones, and the server becomes a handbrake.

P
pwlnw, 2010-12-12
@pwlnw

Start loading and when the server stops serving satisfactorily, write down the load average - it will be 100%.
Of course there are other ways, but why?

V
Veshij, 2010-12-12
@Veshij

If you are only interested in loading by cpu, then you will be satisfied with the data from /proc/stat.
Or, for example, you can run dstat and take csv-formatted data once a second.

D
Dm Po, 2010-12-12
@brick812

top command in ssh console if anything =)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question