Linxu AB 命令:测试服务器性能的利器(linux ab 命令)

Linux AB 命令是由Apache设计,主要用途是用来测试某个网络服务器的性能。AB 命令不仅可以测试HTTP 服务…

Linux AB 命令是由Apache设计,主要用途是用来测试某个网络服务器的性能。AB 命令不仅可以测试HTTP 服务,它也可以用来测试FTP、SMTP等服务的性能。

Linux AB 命令的使用非常简单,只需要一行命令就可以实现:

#ab -n 10000 -c 100 http://www.example.com/

其中,参数 -n 后面接的是请求数,参数 -c 后面接的是并发数,请求的资源是http://www.example.co m/。

运行 ab 后,它会自动执行多次测试,并将统计结果打印出来,如下:

#ab -n 10000 -c 100 http://www.example.com/

This is ApacheBench, Version 2.3

Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/

Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking www.example.com (be patient)

Completed 1000 requests

Completed 2000 requests

Completed 3000 requests

Completed 4000 requests

Completed 5000 requests

Completed 6000 requests

Completed 7000 requests

Completed 8000 requests

Completed 9000 requests

Completed 10000 requests

Finished 10000 requests

Server Software: Apache/2.4.41

Server Hostname: www.example.com

Server Port: 80

Document Path: /

# Concurrency Level: 100

Time taken for tests: 0.942 seconds

Complete requests: 10000

Failed requests: 0

Write errors: 0

Total transferred: 4130000 bytes

HTML transferred: 3800000 bytes

Requests per second: 10643.76 [#/sec] (mean)

Time per request: 9.424 [ms] (mean)

Time per request: 0.094 [ms] (mean, across all concurrent requests)

Transfer rate: 4250.35 [Kbytes/sec] received

Connection Times (ms)

min mean[+/-sd] median max

Connect: 0 0 0.0 0 9

Processing: 1 9 5.2 8 51

Waiting: 0 9 5.1 8 47

Total: 1 9 5.2 8 51

Percentage of the requests served within a certain time (ms)

50% 8

66% 9

75% 10

80% 10

90% 10

95% 11

98% 12

99% 12

100% 51 (longest request)

从上面统计结果中可以看出,该服务器的性能很不错,每秒请求数量可达到10643.76,最大响应时间为51ms,最短响应时间只有8ms。

实际上,Linux AB 命令还有许多其他参数可选,可以根据测试的需求来进行设置,具体参数可以参照AB命令的man 文档来查看。

综上所述,Linux AB 命令是一款能有效测试各种服务器性能的工具,只需要一行命令即可实现,使用非常方便快捷。它所给出的性能数据非常可靠,是优化服务器性能的利器。

香港服务器首选港服(Server.HK),2H2G首月10元开通。
港服(Server.HK)(www.IDC.Net)提供简单好用,价格厚道的香港/美国云服务器和独立服务器。IDC+ISP+ICP资质。ARIN和APNIC会员。成熟技术团队15年行业经验。

为您推荐

ssh远程超时中断的解决办法

有时我们网络正常的,但SSH连接经常出现中断的情况,以及在SSH远程时很慢的问题。 这是由于OpenSSL服务默认启用了...

Linux系统防火墙放行端口

如果您服务器内安装了宝塔面板,请直接登陆宝塔面板,安全,里面添加放行端口。如果添加后不生效,把防火墙开关一下即可。本教程...

Linux主机简单判断被CC攻击的网站命令-比较直接有效

CC攻击很容易发起,并且几乎不需要成本,导致现在的CC攻击越来越多。 大部分搞CC攻击的人,都是用在网上下载的工具,这些...

linux环境下测试get和post请求

Linux环境下测试get和post请求 ?get,post,curl   get请求 curl: curl ...

umount卸载磁盘提示target is busy

umount卸载磁盘提示target is busy. (目标忙) 的问题解决方案   umount卸载磁盘提...
返回顶部