Web site stress and performance testing

https://segmentfault.com/a/1190000011469759

1. Webbench test concurrent
Webbench is a website stress test tool under Linux, which can test the performance of different services on the same hardware and the running status of the same service on different hardware. Standard tests on webbench can show us two things about the server: the number of corresponding requests per minute and the amount of data transferred per second. Webbench can simulate up to 30,000 concurrent connections to test the load capacity of the website.

The test environment is Linux Ubuntu

1. Install
1.1 Install ctags

apt-get install exuberant-ctags
ctags is a webbench dependency

1.2 Download and install

Official website: http://home.tiscali.cz/~cz210...

[email protected]:~# wget http://home.tiscali.cz/~cz210552/distfiles/webbench-1.5.tar.gz
[email protected]:~# tar zxvf webbench-1.5.tar.gz
[email protected]:~# cd webbench-1.5/
root @corwien:~/webbench-1.5# make
[email protected]:~/webbench-1.5# make install
[email protected]:~/webbench-1.5# webbench
webbench [option]... URL
-f|--force Don't wait for reply from server.
-r|--reload Send reload request - Pragma: no-cache.
-t|--time <sec> Run benchmark for <sec> seconds. Default 30.
-p|--proxy <server:port> Use proxy server for request.
-c|--clients <n> Run <n> HTTP clients at once. Default one.
-9|--http09 Use HTTP/0.9 style requests.
-1|--http10 Use HTTP/1.0 protocol.
-2|--http11 Use HTTP/1.1 protocol.
--get Use GET request method.
--head Use HEAD request method.
--options Use OPTIONS request method.
--trace Use TRACE request method.
-?|-h|--help This information.
-V|--version Display program version.
2. Test
Usage:

// webbench -c concurrent number -t running test time URL
webbench -c 100 -t 10 http://baidu.com/
Here is a test using Baidu ^_^:

test result:


result analysis:
response per second The number of requests: 1443/60= X pages/sec, the amount of data transmitted per second is 2691621 bytes/sec.

When there are 500 concurrent requests, 1402 requests are successfully made, and 41 connections have been shown to have failed, indicating that the load is overloaded.

3. Summary:
1. The stress and performance testing work should be done before the product is launched, not after it is launched;
2. The concurrency should be gradually increased during testing. For example, when the concurrency is 100, observe the load of the website and whether the opening page is smooth. , what is the concurrency of 200, what is the concurrency when the website opens slowly, and how much is the concurrency when the website cannot be opened;
3. Conduct a page test in more detail, such as e-commerce websites can focus on testing shopping carts, promotion pages, etc. , because these pages account for a large proportion of the entire website traffic.

Remarks: When webbench performs stress and performance tests, the software itself will consume CPU and memory resources. In order to test accurately, it is recommended to install webbench on other servers to achieve more accurate test data.

2. Practical
combat I learned how to use webbench for stress testing. Now I use this tool to test my blog. My blog server uses Alibaba Cloud ECS. When the concurrency is from 100 to 500, look at the server's CPU. Utilization rate and memory usage, when there are too many concurrency, will the CPU be used up and whether the website can be accessed normally at this time? Our purpose is to measure how much concurrency the website can withstand.

1. Use the top command to view the server resource usage
Before the actual measurement, first learn the meaning of the parameters of the top command: The

top command is a common performance analysis tool under Linux, which can display the resource usage of each process in the system in real time, similar to Windows Task Manager.

top displays the current process and other status of the system. It is a dynamic display process, that is, the current status can be continuously refreshed through the user's keystrokes. If the command is executed in the foreground, it will occupy the foreground until the user terminates the program. More precisely The ,top command provides real-time monitoring of the system's processor status. It will display a list of the most "sensitive" tasks for the CPU in the system. The command can sort tasks by CPU usage, memory usage, and execution time; and the command's Many features can be set via interactive commands or in custom files.

[email protected]:~# top -d 2
top - 01:22:59 up 690 days, 9:42, 1 user, load average: 0.09 , 0.05, 0.05
Tasks: 117 total, 2 running, 115 sleeping, 0 stopped, 0 zombie
%Cpu(s): 0.0 us, 0.5 sy, 0.0 ni, 99.0 id, 0.0 wa, 0.0 hi, 0.0 si, 0.5 st
KiB Mem: 1016272 total, 886640 used, 129632 free, 163252 buffers
KiB Swap: 1048572 total, 37120 used, 1011452 free. 449744 cached Mem

  PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
15875 root 20 0 139156 15048 9420 S 0.5 1.5 15:17.66 AliYunDun
    1 root 20 0 33372 1388 320 S 0.0 0.1 0:21.49 init
    2 root 2 0.0 0.0 0:00.00 The
first five lines of the kthreadd statistics area are the overall system statistics. The first line is the task queue information, which is the same as the execution result of the uptime command. Its content is as follows:

01:22:59 Current time
up 690 days, 9:42, system running time, format is days, hour:minute
1 user, current number of logged-in users
load average: 0.09, 0.05, 0.05 System load, that is, task Average length of the queue. The three values ​​are the average values ​​from 1 minute, 5 minutes, and 15 minutes ago to the present.
The second and third behaviors are information about the process and CPU. These may exceed two lines when there are multiple CPUs. The contents are as follows:

total total number
of processes running number of running processes sleeping number of
sleeping processes stopped number of
stopped processes zombie number of
zombie processes
Cpu(s):
0.3% us The percentage of CPU occupied by user space
1.0% sy The percentage of CPU occupied by kernel space
0.0% ni The percentage of CPU occupied by processes whose priorities have changed in user process space
98.7% id The percentage of idle CPU
0.0% wa The percentage of CPU time waiting for input and output
0.0% hi: hardware CPU interrupt occupancy percentage
0.0% si: soft interrupt occupancy percentage
0.0% st: virtual machine occupancy percentage
The last two lines are memory information. The contents are as follows:

Mem:
191272k total total physical memory
173656k used total physical memory used
17616k free total free memory
22052k buffers memory used as kernel cache
Swap:
192772k total total swap area
0k used total used swap area
192772k free The total amount of free swap area
123988k The total amount of cached buffered swap area, the content in the memory is swapped out to the swap area, and then swapped into the memory, but the used swap area has not been overwritten, the value is these The size of the swap area where the content already exists in the memory. When the corresponding memory is swapped out again, there is no need to write to the swap area.
The lower part of the statistics area of ​​the process information area shows the detailed information of each process. First, let's understand the meaning of each column.

No. Column Name Meaning
a PID Process id
b PPID parent process id
c RUSER Real user name
d UID process owner's user id
e USER process owner's user name
f GROUP process owner's group name
g TTY start process terminal name. Processes not started from the terminal are displayed as ?
h PR priority
i NI nice value. Negative value means high priority, positive value means low priority
j P The last CPU used, only meaningful in a multi-CPU environment
k %CPU The percentage of CPU time occupied by the last update to the present
l TIME The total CPU time used by the process, Unit second
m TIME+ Total CPU time used by process, unit 1/100 second
n %MEM Percentage of physical memory used by
process o VIRT Total virtual memory used by process, unit kb. VIRT=SWAP+RES
p In the virtual memory used by the SWAP process, the size that is swapped out, in kb.
q The size of the physical memory used by the RES process and not swapped out, in kb. RES=CODE+DATA
r CODE Physical memory size occupied by executable code, unit kb
s DATA Physical memory size occupied by parts other than executable code (data segment + stack), unit kb
t SHR Shared memory size, in kb
u nFLT Number of page faults
v nDRT The number of pages that have been modified since the last write to the present.
w S Process state (D=uninterruptible sleep state, R=running, S=sleep, T=trace/stop, Z=zombie process)
x COMMAND command name/command line
y WCHAN If the process is sleeping, display sleep The system function name in
z Flags task flags, refer to sched.h
By default, only the more important PID, USER, PR, NI, VIRT, RES, SHR, S, %CPU, %MEM, TIME+, COMMAND columns are displayed. The display content can be changed by the shortcut keys below.

Change the display content The f key can select the display content. After pressing the f key, a list of columns will be displayed, press az to show or hide the corresponding column, and finally press the Enter key to confirm.
Press the o key to change the order in which the columns are displayed. Press lowercase az to move the corresponding column to the right, and uppercase AZ to move the corresponding column to the left. Finally press Enter to confirm.
Press the uppercase F or O key, then az to sort the processes by the appropriate column. The uppercase R key reverses the current sorting.

The command uses the
top format

top [-] [d] [p] [q] [c] [C] [S] [s] [n]

Parameter description

d specifies the time interval between every two screen information refreshes. Of course the user can use the s interactive command to change it.
p Monitor only the status of a process by specifying the monitor process ID.
q This option will make top refresh without any delay. If the calling program has superuser privileges, then top will run with the highest possible priority.
S Specifies cumulative mode
s to make the top command run in safe mode. This removes the potential danger posed by interactive commands.
i makes top not show any idle or zombie processes.
c Display the entire command line instead of just the command name
2, stress test and view the server top resource usage at the same time 1,
500 concurrent load stress test

[email protected]:~# webbench -c 500 -t 60 http://myblog.com /index.php

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326698836&siteId=291194637