负载测试(Load Testing): Large amount of users, 从小的负荷开始, 逐渐增加负载, 观察不同负载下应用程序的响应时间,消耗资源等等, 它是测试系统在不同工作负荷(负载)下的性能指标, 从而了解服务器的工作能力.
压力测试(Stress Testing): Too many users, too much data, too little time and too little root, 在负荷条件(系统资源极少)情况下系统长时间运行的稳定性, 利用脚本故意吃掉服务器部分 CPU/内存/带宽等方式, 亦或者大业务量情况下导致的服务器资源不足, 从而观察系统的稳定性 , 测试系统是否发生崩溃, 宕机, 无法请求等问题, 找到系统某项功能的隐患, 发现系统是否拥有良好的容错能力, 恢复能能力. 压力测试分为: 稳定性压力测试, 破坏性压力测试.
容量测试(Volume Test): Large amount of data, 测试预先分析的指标极限值(最大并发等), 测试系统在极限情况下运行状态.
Usage: ab [options] [http[s]://]hostname[:port]/path
options are: -n requests 指定压力测试的总执行次数 -c concurrency 指定压力测试的并发数 -t timelimit 指定时间内发送全部请求, 默认隐含的-n值为 50000 -s timeout 请求响应最大超时, 默认 30S -b windowsize TCP 发送和接收缓冲池大小(字节) -B address Address to bind to when making outgoing connections -p postfile File containing data to POST. Remember also to set -T -u putfile File containing data to PUT. Remember also to set -T -T content-type Content-type header to use for POST/PUT data, eg. 'application/x-www-form-urlencoded' Default is 'text/plain' -v verbosity How much troubleshooting info to print -w HTML 格式打印结果 -i 使用 HEAD 请求代替 GET -x attributes 插入字符串作为table标签的属性 -y attributes 插入字符串作为tr标签的属性 -z attributes 插入字符串作为td, th标签的属性 -C attribute Add cookie, eg. 'Apache=1234'. (repeatable) -H attribute Add Arbitrary header line, eg. 'Accept-Encoding: gzip' Inserted after all normal header lines. (repeatable) -A attribute Add Basic WWW Authentication, the attributes are a colon separated username and password. -P attribute Add Basic Proxy Authentication, the attributes are a colon separated username and password. -X proxy:port Proxyserver and port number to use -V Print version number and exit -k 使用HTTP 的KeepAlive特性 -d 不显示百分比. -S 不显示预估和警告信息. -q Do not show progress when doing more than 150 requests -l Accept variable document length (use this for dynamic pages) -g filename Output collected data to gnuplot format file. -e filename Output CSV file with percentages served -r 发生socket连接错误也不退出 -m method Method name -h Display usage information (this message) -I Disable TLS Server Name Indication (SNI) extension -Z ciphersuite Specify SSL/TLS cipher suite (See openssl ciphers) -f protocol Specify SSL/TLS protocol (TLS1, TLS1.1, TLS1.2 or ALL) -E certfile Specify optional client certificate chain and private key
This is ApacheBench, Version 2.3 <$Revision: 1879490 $> Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/ Licensed to The Apache Software Foundation, http://www.apache.org/
Concurrency Level: 130 并发数 Time taken for tests: 2.024 seconds 整个测试持续时间 Complete requests: 900 完成请求数目 Failed requests: 0 失败的请求数目 Total transferred: 153000 bytes 整个测试场景的网络传输字节 HTML transferred: 9000 bytes 整个测试场景的HTML 内容传输字节
Requests per second: 444.72 [#/sec] (mean) 平均每秒的请求数 Time per request: 292.318 [ms] (mean) 平均事务响应时间, 并发客户端都请求一次的平均时间 Time per request: 2.249 [ms] (mean, across all concurrent requests) 每个请求实际运行时间的平均值 Transfer rate: 73.83 [Kbytes/sec] received 平均每秒网络上的流量
Connection Times (ms) 网络上消耗的时间的分解 min mean[+/-sd] median max Connect: 0 3 4.3 1 23 Processing: 203 239 32.0 226 312 Waiting: 201 236 30.7 222 308 Total: 203 242 31.6 232 313
Percentage of the requests served within a certain time (ms) 整个场景中所有请求的响应情况 50% 232 66% 254 75% 275 80% 279 90% 287 95% 296 98% 307 99% 309 100% 313 (longest request)