Home >Backend Development >PHP Tutorial >Introduction, installation and use of website stress testing tool webbench

Introduction, installation and use of website stress testing tool webbench

WBOY
WBOYOriginal
2016-08-08 09:27:561292browse
I have been looking for an effective website stress testing article "> website stress testing tool. After trying webbench today, I feel very satisfied, and I would like to share it with you. 1. Introduction to webbenchWebbench is a famous website stress testing tool, which was developed by Lionbridge Company (http://www.lionbridge.com). Its help files and documentation can be viewed at: www.webbench.com.
Webbech can test the performance of different services on the same hardware and the running status of the same service on different hardware. webBech's standard test can show us two things about the server: the number of corresponding requests per second and the amount of data transferred per second. Webbench not only has the ability to test static pages, but also has the ability to test dynamic pages (ASP, PHP, JAVA, CGI). In addition, it supports static or dynamic performance testing of secure websites containing SSL, such as e-commerce websites.
2. Webbench installation (1) Installation method using Ports under FreeBSD:

#cd /usr/ports/benchmarks/webbench
#make install clean

Remember to run it after the installation is successful rehash command, refresh the system command

#rehash

(2) Compilation and installation under RedHat/CentOSDownload the installation package: wget http://blog.s135.com/soft/linux/webbench/webbench -1.5.tar.gz

#tar zxf webbench-1.5.tar.gz
#cd webbench-1.5
#make && make install

or refer to: http://blog.haohtml.com/index. php/archives/32343. Using webbench

#webbench -? (View command help)

Common parameter description, -c represents the number of clients, -t represents timeTest example:

#webbench -c 500  -t  30   http://192.168.0.99/phpionfo.php

测试静态图片

#webbench -c 500  -t  30   http://192.168.0.99/test.jpg

四、webbench测试结果

www# webbench -c 500 -t 30 http://192.168.0.99/phpionfo.php

Webbench - Simple Web Benchmark 1.5

Copyright (c) Radim Kolar 1997-2004, GPL Open Source Software.

Benchmarking: GET http://192.168.0.99/phpionfo.php

500 clients, running 30 sec.

Speed=53726 pages/min, 160866 bytes/sec.

Requests: 26863 susceed, 0 failed.

五、webbench命令

webbench [option]... URL

-f|--force               Don't wait for reply from server.

-r|--reload              Send reload request - Pragma: no-cache.

-t|--time          Run benchmark for seconds. Default 30.

-p|--proxy Use proxy server for request.

-c|--clients         Run 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.

六 实例演示(Nginx+php和Apache+php)注意:webbench 做压力测试时,该软件自身也会消耗CPU和内存资源,为了测试准确,请将 webbench 安装在别的服务器上。测试结果:##### Nginx + PHP #####

[root@localhost webbench-1.5]# webbench -c 100 -t 30http://192.168.1.21/phpinfo.php
Webbench - Simple Web Benchmark 1.5
Copyright (c) Radim Kolar 1997-2004, GPL Open Source Software.

Benchmarking: GET http://192.168.1.21/phpinfo.php
100 clients, running 30 sec.

Speed=102450 pages/min, 16490596 bytes/sec.
Requests: 51225 susceed, 0 failed.

top - 14:06:13 up 27 days,  2:25,  2 users,  load average: 14.57, 9.89, 6.51
Tasks: 287 total,   4 running, 283 sleeping,   0 stopped,   0 zombie
Cpu(s): 49.9% us,  6.7% sy,  0.0% ni, 41.4% id,  1.1% wa,  0.1% hi,  0.8% si
Mem:   6230016k total,  2959468k used,  3270548k free,   635992k buffers
Swap:  2031608k total,     3696k used,  2027912k free,  1231444k cached


测试结果:#####  Apache + PHP #####

[root@localhost webbench-1.5]# webbench -c 100 -t 30http://192.168.1.27/phpinfo.php
Webbench - Simple Web Benchmark 1.5
Copyright (c) Radim Kolar 1997-2004, GPL Open Source Software.

Benchmarking: GET http://192.168.1.27/phpinfo.php
100 clients, running 30 sec.

Speed=42184 pages/min, 31512914 bytes/sec.
Requests: 21092 susceed, 0 failed.

top - 14:06:20 up 27 days,  2:13,  2 users,  load average: 62.15, 26.36, 13.42
Tasks: 318 total,   7 running, 310 sleeping,   0 stopped,   1 zombie
Cpu(s): 80.4% us, 10.6% sy,  0.0% ni,  7.9% id,  0.1% wa,  0.1% hi,  0.9% si
Mem:   6230016k total,  3075948k used,  3154068k free,   379896k buffers
Swap:  2031608k total,    12592k used,  2019016k free,  1117868k cached

可以看出Nginx+php平台的并发量(51225)要比Apache+php平台的并发量(21092)要大的.为什么Nginx的性能要比Apache高得多?这得益于Nginx使用了最新的epoll(Linux 2.6内核)和kqueue(freebsd)网络I/O模型,而Apache则使用的是传统的select模型。目前Linux下能够承受高并发访问的 Squid、Memcached都采用的是epoll网络I/O模型。处理大量的连接的读写,Apache所采用的select网络I/O模型非常低效。下面用一个比喻来解析Apache采用的select模型和Nginx采用的epoll模型进行之间的区别:Suppose you are studying in college and live in a dormitory with many rooms, and your friends want to come to you. In the select version, the hostess will take your friends to look for you from room to room until they find you. In the epoll version, the dormitory aunt will first write down the room number of each student. When your friend comes, you only need to tell your friend which room you live in. There is no need to take your friend around the building to find someone. If 10,000 people come and want to find their classmates who live in this building, it is self-evident which one is more efficient, the select version or the epoll version of the dormitory aunt. Similarly, in high-concurrency servers, polling I/O is one of the most time-consuming operations. It is also very clear which performance is higher between select and epoll.
From: http://blog.haohtml.com/archives/6144

The above has introduced the introduction, installation and use of the website stress testing tool webbench, including the relevant aspects. I hope it will be helpful to friends who are interested in PHP tutorials.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn