Pressure measurement tool:
Tool Description Usage Featuresaway | Simulate multiple visitors accessing a URL address at the same time (nginx, tomcat, lighthttp) Simulate multi-threaded concurrent requests |
ab -c 100 -n 1000 http://www.baidu.com/ |
It's good to do repetitive stress tests, but you can only test one link at a time |
http_load |
http_load runs in parallel multiplexing to test the throughput and load of the web server. It can run as a single process, which generally does not kill the client. It can also test https -like website requests. The program is very small. , less than 100k |
http_load -p 30 (number of processes) -s 60 (total access time) urllist.txt |
The main indicators in the test results are the options fetches/sec and msecs/connect , that is, the number of queries the server can respond to per second |
webbench |
webbench is a website stress testing tool under Linux , which can simulate up to 30,000 concurrent connections to test the load capacity of the website The program is relatively small, less than 50k |
webbench -c concurrency number -t run test time URL |
Can simulate up to 30,000, the limit is too large |
Siege |
An open source stress testing tool that can perform concurrent access to a WEB site by multiple users according to the configuration, record the corresponding time of all request processes of each user, and repeat the process under a certain number of concurrent accesses |
siege -c 200 -r 10 -f example.url |
Request random URLs in the preset list, siege can be used to simulate user request load |
Note: 1. The above pressure measurement can only simulate flow pressure measurement, and cannot achieve real flow pressure measurement
2. Cannot simulate the online environment in real time
Pressure measurement of online drainage method:
Advantages and disadvantages of drainage methodsTraffic replication at the nginx layer | Copy the request to the test environment through the lua script | Simple installation and deployment | Lua scripts need to be developed, which will occupy a certain amount of resources |
Drainage based on business code layer | The encapsulation layer request object of the business code is asynchronously written into the cache, and the drainage tool reads the cache by reading the The request object in , want to initiate a request in the stress test environment |
Good scalability | Need to develop traffic replication tools, the workload is not small |
Access log playback based on logs | The online system records the access log, and the traffic drainage tool initiates a request to the test environment by parsing the log | Offline mode has little impact on online | A log parsing tool needs to be developed, and the parsing overhead is relatively high |
Drainage based on TCP/IP layer | The open source tool tcpcopy is currently available | Simple installation and deployment | There is a packet loss rate, only IP is supported, for long connections (uploading files), it is not very supported |
1. Introduction:
Tcpcopy is a distributed online stress measurement tool that can copy online traffic to the test machine and simulate the online environment in real time
Tcpcopy is a project open sourced by NetEase Technology Department in September 2011
2. Structure diagram:
3. Workflow:
1. An access to the online front-end machine
2. The socket data packet is copied at the IP layer to the tcpcopy process
3. tcpcopy modifies the purpose and source address of the package and sends it to the test machine
4. The copy package arrives at the test machine
5. The nginx of the target test machine processes the access and returns the result
6. The returned result is intercepted and discarded at the IP layer, and the ip header of the result is copied by the intercept process and returned
7. The ip header is returned to the tcpcopy process of the front-end machine (due to the removal of the body layer, there is only header data, and the load pressure is small)
4. Two working modes:
1. Copy data packets in real time
2、通过使用tcpdump等抓包生成的文件进行离线(offline)请求重放
五、两种模式的实现:
1、实时拷贝
tcpdump -i eth0 -w online.pcap tcp and port 80
-i eth0:eth0为网卡,获取方式可在liunx系统下执行ifconfig查看所有的网卡,选取需要的那个。 -w online.pcap:为获取pcap文件进行回放,可设置路径,e.g. -w /home/user/test.pcap tcp and port 80:截获端口为80的tcp请求,也可添加udp请求,和更改服务端口80,e.g. tcp and port 16001 -s 0:默认的话,tcpdump只显示部分数据包,-s snaplen是控制包长度的,默认是68字节,-s 0 则为全部字节,在使用过程中,如果添加-s则回放时会出现错误。可不使用该参数
回放:
1 whereis tcpcopy,可在/usr/local/tcpcopy/sbin下发现tcpcopy命令 2 ./tcpcopy -x 16001-服务器ip:16001 -s 服务器ip -i /home/user/test.pcap 3 服务端抓包测试:tcpdump -n port 16001