温欣爸比

  • 主页
  • Alfred Workflow
  • 《Vim 练级手册》
  • 常用命令
  • 代码笔记
  • 合辑
  • 在线工具
所有文章 友链 关于我

温欣爸比

  • 主页
  • Alfred Workflow
  • 《Vim 练级手册》
  • 常用命令
  • 代码笔记
  • 合辑
  • 在线工具

Linux ab 压力测试

2019-01-06

ab 是 Apache 附带的接口压力测试功能,非常简单易用。在测试服务端程序自身运行时长和跨区测试接口反馈时长时非常有用。



  • 下载
  • 使用

下载

CentOS

1
$ sudo yum install -y httpd

Ubuntu

1
$ sudo apt install -y apache2-utils

使用

1
$ ab -c 10 -n 100 http://ip-api.com/json

参数

  • -c: 表示并发数
  • -n: 表示请求总数

结果

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
> $ ab -c 10 -n 100 http://ip-api.com/json
This is ApacheBench, Version 2.3 <$Revision: 1807734 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking ip-api.com (be patient).....done


Server Software:
Server Hostname: ip-api.com
Server Port: 80

Document Path: /json
Document Length: 306 bytes

Concurrency Level: 10
Time taken for tests: 6.184 seconds
Complete requests: 100
Failed requests: 0
Total transferred: 46200 bytes
HTML transferred: 30600 bytes
Requests per second: 16.17 [#/sec] (mean)
Time per request: 618.369 [ms] (mean)
Time per request: 61.837 [ms] (mean, across all concurrent requests)
Transfer rate: 7.30 [Kbytes/sec] received

Connection Times (ms)
min mean[+/-sd] median max
Connect: 1 3 1.1 3 6
Processing: 528 572 58.4 550 889
Waiting: 528 571 58.7 549 888
Total: 531 575 58.3 552 891

Percentage of the requests served within a certain time (ms)
50% 552
66% 565
75% 574
80% 600
90% 635
95% 656
98% 890
99% 891
100% 891 (longest request)

结果详解

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
Server Software:        web服务器软件及版本
Server Hostname: 请求的地址
Server Port: 请求的端口

Document Path: 请求的页面路径
Document Length: 页面大小

Concurrency Level: 并发数
Time taken for tests: 测试总共花费的时间
Complete requests: 完成的请求数
Failed requests: 失败的请求数
Write errors: 写入错误
Total transferred: 总共传输字节数,包含http的头信息等
HTML transferred: html字节数,实际的页面传递字节数
Requests per second: 每秒处理的请求数,服务器的吞吐量(重要)
Time per request: 平均数,用户平均请求等待时间
Time per request: 服务器平均处理时间
Transfer rate: 平均传输速率(每秒收到的速率)

Time per request 是我们测试接口时长时非常关键的字段。

  • linux下web压力测试工具ab使用及详解
最近更新
Alfred Workflow 命令行帮助工具
最近热读
Go 判断数组中是否包含某个 item
Vim 高级功能 vimgrep 全局搜索文件
办理北京工作居住证的一些细节
Go 语法错误:Non-declaration statement outside function body
Mac 电脑查看字体文件位置
扫码关注公众号,或搜索公众号“温欣爸比” 及时获取我的最新文章
赏

谢谢你请我喝咖啡

支付宝
微信
  • linux
2019 年读书目录
重新学 Java 系列:为什么要用 set、get 方法
  1. 1. 下载
  2. 2. 使用
© 2017 - 2022 温欣爸比 京ICP备15062634号 总访问量3525次 访客数3477人次 本文总阅读量2次
Hexo Theme Yilia by Litten
  • 所有文章
  • 友链
  • 关于我

tag:

  • python
  • flask
  • javascript
  • docker
  • 工具
  • openresty
  • 微信
  • java
  • hexo
  • 杂谈
  • vim
  • git
  • mysql
  • http
  • linux
  • mac
  • tmux
  • ssh
  • 算法
  • 开发
  • node
  • 杂文
  • jinja2
  • maven
  • spring
  • 北京
  • 生活
  • springboot
  • react
  • shell
  • graphql
  • iterm
  • expect
  • nginx
  • sqlalchemy
  • html
  • electron
  • vagrant
  • elastic
  • 宝贝
  • ansible
  • css
  • jquery
  • go
  • markdown
  • awk
  • redis
  • leetcode
  • zsh
  • 漫威
  • ssr
  • android
  • ffmpeg
  • chrome
  • vmware
  • youtube
  • windows
  • jupyter
  • excel
  • jq
  • Mac
  • Homebrew
  • mongo
  • py2
  • HomeBrew
  • movie
  • nodejs

    缺失模块。
    1、请确保node版本大于6.2
    2、在博客根目录(注意不是yilia根目录)执行以下命令:
    npm i hexo-generator-json-content --save

    3、在根目录_config.yml里添加配置:

      jsonContent:
        meta: false
        pages: false
        posts:
          title: true
          date: true
          path: true
          text: false
          raw: false
          content: false
          slug: false
          updated: false
          comments: false
          link: false
          permalink: false
          excerpt: false
          categories: false
          tags: true
    

  • Guru99
每天看书
每天背单词
每天一篇
写写代码
听听周杰伦
爱爱老婆