Detailed explanation of pressure measurement AB and monitoring tools

Posted Jun 27, 20205 min read

Client Pressure Test Tool AB

ab(option)(parameter) address

-A:Specify the basic authentication credentials to connect to the server;
-c:Specify the number of requests to the server at one time;
-C:add cookie;
-g:output the test results as a "gnuolot" file;
-h:display help information;
-H:append an extra header to the request;
-i:use the "head" request method;
-k:activate the "keepAlive" feature in HTTP;
-n:Specify the number of requests used in the test session;
-p:specify the file containing the data;
-q:do not display the progress percentage;
-T:When using POST data, set the content type header;
-v:set the detailed mode level;
-w:print the results in HTML form;
-x:When outputting in the form of a table, set the properties of the table;
-X:Use the specified proxy server to send the request;
-y:Set the table properties when outputting as a table.

ab -c 200 -n 200

operation result

This is ApacheBench, Version 2.3 <$Revision:1748469 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd,
Licensed to The Apache Software Foundation,

Benchmarking patient)
Completed 100 requests
Completed 200 requests
Finished 200 requests

Server Software:
Server Hostname: #domain name
Server Port:3000 #Request port number

Document Path:/#File path
Document Length:11 bytes #Page bytes

Concurrency Level:200 #Number of concurrent requests
Time taken for tests:0.192 seconds #Total access time
Complete requests:200 #Number of successful requests
Failed requests:0 #Number of failed requests
Total transferred:29400 bytes #Request total data size(including header information)
HTML transferred:2200 bytes #html page actual total bytes
Requests per second:1041.68 [#/sec](mean) #How many requests per second
Time per request:191.998 [ms](mean) #User average request waiting time
Time per request:0.960 [ms](mean, across all concurrent requests) # server average processing time
Transfer rate:149.54 [Kbytes/sec]received #Data length acquired per second

Connection Times(ms)
              min mean[+/-sd]median max
Connect:0 0 0.3 0 1
Processing:9 94 49.2 95 179
Waiting:3 90 51.0 91 178
Total:9 95 49.2 95 179

Percentage of the requests served within a certain time(ms)
  50%95 #50%of user requests are returned within 95ms
  66%122 #66%user requests to return within 122ms
  75%138 #75%of user requests return within 138ms
  80%146 #80%of user requests return within 146ms
  90%163 #90%of user requests return within 163ms
  95%171 #95%user requests to return within 171ms
  98%176 #98%user requests to return within 176ms
  99%178 #99%user requests to return within 178ms
 100%179(longest request)

This focuses on two values Requests per second(QPS) and Transfer rate(throughput), the higher the throughput, the better the performance of the server.

Node comes with profile

node --prof index.js

Server monitoring

The client server also needs to enable monitoring to detect specific problems

View cpu and memory usage

[root@VM_0_4_centos ~]# top
top-01:19:19 up 6 days, 9 min, 1 user, load average:0.00, 0.01, 0.05
Tasks:122 total, 1 running, 121 sleeping, 0 stopped, 0 zombie

%Cpu(s):0.2 us, 0.2 sy, 0.0 ni, 99.7 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st
KiB Mem:3880224 total, 235108 free, 973224 used, 2671892 buff/cache
KiB Swap:0 total, 0 free, 0 used. 2615988 avail Mem

    1 root 20 0 43692 3692 2288 S 0.0 0.1 0:32.31 systemd

Line 1:Overview

  1. Current time 01:19:19;
  2. The elapsed time from this boot to the present up 6 days, 9 min;
  3. Several users are currently logged into the machine. 1 user;
  4. The average load value of the system within 1 minute, 5 minutes and 15 minutes load average:0.00, 0.01, 0.05

Second line:Process count(Tasks)

  1. The total number of processes 122 total;
  2. The number of running processes 1 running;
  3. The number of sleeping processes 121 sleeping;
  4. The number of stopped processes 0 stopped;
  5. The number of zombie processes 0 zombie

Third line:CPU usage(%Cpu(s))

  1. The proportion of CPU time consumed by a process in user space(user), excluding processes whose priority has been adjusted. %Cpu(s):0.2 us
  2. The proportion of CPU time consumed by the process in the kernel space(system). 0.2 sy
  3. Adjusted the proportion of CPU time of the user mode priority(niced) process. 0.0 ni
  4. Proportion of idle CPU time. 99.7 id
  5. Proportion of CPU time waiting for I/O completion. 0.0 wa
  6. Proportion of CPU time to handle hardware interrupts. 0.0 hi
  7. Proportion of CPU time handling software interrupts. 0.0 si
  8. When the Linux system is running in a virtual machine, the proportion of waiting time for CPU resources(steal time). 0.0 st

The fourth and fifth lines:physical memory and swap space(Mem/Swap)

  1. Total memory. 3880224 total
  2. The amount of free memory. 235108 free
  3. The amount of memory in use. 973224 used
  4. The amount of memory used by cache and page cache. 2671892 buff/cache

Next is the process details

  1. PID process ID
  2. The username of the USER process owner.
  3. PR process scheduling priority from the perspective of the system kernel.
  4. The nice value of the NI process, which is the process priority from the user space perspective. The lower the value, the higher the priority.
  5. The amount of virtual memory requested by the VIRT process.
  6. The amount of resident memory(that is, memory that has not been swapped out) used by the RES process.
  7. The amount of shared memory used by the SHR process.
  8. S process status. R=running, S=interruptible sleeping, D=uninterruptible sleeping, T=stopped, Z=zombie.
  9. The percentage of CPU time that the %CPU process occupies during an update cycle.
  10. The proportion of physical memory occupied by the %MEM process.
  11. The length of CPU time occupied by TIME+ process since its creation.
  12. The command used by COMMAND to run the process.

iostat view hard disk bandwidth command

[root@VM_0_4_centos ~]# yum install -y sysstat
[root@VM_0_4_centos ~]# iostat
Linux 3.10.0-1062.18.1.el7.x86_64(VM_0_4_centos) 06/27/2020 _x86_64_(2 CPU)

           0.35 0.00 0.20 0.09 0.00 99.35

Device:tps kB_read/s kB_wrtn/s kB_read kB_wrtn
vda 3.10 3.39 22.73 1758510 11783276
vdb 1.69 5.79 14.56 3001589 7547888
scd0 0.00 0.00 0.00 910 0

%user:The percentage of time the CPU is in user mode.

%nice:The percentage of time the CPU is in user mode with NICE value.

%system:The percentage of time the CPU is in system mode.

%iowait:The percentage of time the CPU waits for input and output completion.

%steal:The percentage of unconscious wait time of the virtual CPU when the hypervisor maintains another virtual processor.

%idle:percentage of CPU idle time.

tps:the number of transmissions per second of the device

kB_read/s:the amount of data read from the device(drive expressed) per second;

kB_wrtn/s:the amount of data written to the device(drive expressed) per second;

kB_read:the total amount of data read;

kB_wrtn:the total amount of data written;


If the value of%iowait is too high, it indicates that the hard disk has an I/O bottleneck

If the%idle value is high, the CPU is idle

If the%idle value is high but the system response is slow, it may be that the CPU is waiting to allocate memory. Increase the memory capacity.

If the%idle value continues to be lower than 10, it indicates that the CPU processing power is relatively low, and the most needed resource in the system is the CPU.

Common commands

# Refresh the display every 2 seconds and display 3 times
iostat 2 3

# Display specified disk information
iostat -d /dev/vdb1

# Display tty and cpu information
iostat -t

# Display all information in units of M
iostat -m

# View device usage rate(%util), response time(await)
iostat -d -x -k 1 1

Related Posts