如何测量Apache/Lighttpd/IIS Web服务器的侦听和吞吐量
时间:2020-01-09 10:42:17 来源:igfitidea点击:
问题描述:我可以使用标准的UNIX/Linux命令行实用工具来测量网络吞吐量和数据包丢失。
如何查找Linux下的Apache之类的Web服务器的侦听和吞吐量?
解决方法:您需要使用名为httping的程序。
它允许您测量Web服务器的延迟和吞吐量。
在主机www.theitroad.local上Ping Web服务器
使用以下命令测量延迟。
按CTRL + c退出程序。
它将显示测量结果的摘要。
$ httping -g http://www.theitroad.local
输出:
PING www.theitroad.local:80 (http://www.theitroad.local): connected to www.theitroad.local:80, seq=0 time=981.08 ms connected to www.theitroad.local:80, seq=1 time=709.92 ms connected to www.theitroad.local:80, seq=2 time=1072.02 ms connected to www.theitroad.local:80, seq=3 time=903.81 ms connected to www.theitroad.local:80, seq=4 time=607.84 ms connected to www.theitroad.local:80, seq=5 time=660.01 ms connected to www.theitroad.local:80, seq=6 time=730.12 ms connected to www.theitroad.local:80, seq=7 time=781.49 ms
-g url选项用于选择要探测/ping的URL。
您还可以使用-p port选项指定端口:
$ httping -g http://www.theitroad.local -p 81
您还可以使用SSL进行连接,要使其正常工作,您需要提供https网址或者443端口号:
$ httping -l -g https://www.theitroad.local
或者
$ httping -g http://www.theitroad.local -p 443
测量Web服务器的吞吐量
-G选项强制执行GET请求而不是HEAD请求,这意味着还必须传输完整的页面/文件。
您还需要将-b选项与-G选项一起传递,以获取传输速度(以KB/s为单位)。
$ httping -Gbg http://www.theitroad.local/
输出:
PING www.theitroad.local:80 (http://www.theitroad.local/): connected to www.theitroad.local:80, seq=0 time=1738.39 ms 22KB/s connected to www.theitroad.local:80, seq=1 time=1650.19 ms 20KB/s connected to www.theitroad.local:80, seq=2 time=1759.65 ms 17KB/s connected to www.theitroad.local:80, seq=3 time=1589.98 ms 21KB/s connected to www.theitroad.local:80, seq=4 time=3709.87 ms 6KB/s connected to www.theitroad.local:80, seq=5 time=3329.69 ms 7KB/s .... ..... --- http://www.theitroad.local/ ping statistics -- 53 connects, 53 ok, 0.00% failed round-trip min/avg/max = 1451.9/2013.6/11656.0 ms Transfer speed: min/avg/max = 6/19/24 KB
请注意以上命令中的您不再测量延迟!
您还可以将-X选项与-G一起使用,以显示传输的数据量(不包括标题):
$ httping -XGbg http://www.theitroad.local/
输出:
PING www.theitroad.local:80 (http://www.theitroad.local/): connected to www.theitroad.local:80, seq=0 time=1576.11 ms 22KB/s 19KB connected to www.theitroad.local:80, seq=1 time=2620.26 ms 9KB/s 19KB connected to www.theitroad.local:80, seq=2 time=1507.69 ms 23KB/s 19KB connected to www.theitroad.local:80, seq=3 time=1522.08 ms 24KB/s 19KB connected to www.theitroad.local:80, seq=4 time=1533.68 ms 23KB/s 19KB connected to www.theitroad.local:80, seq=5 time=1581.92 ms 21KB/s 19KB connected to www.theitroad.local:80, seq=6 time=1512.06 ms 24KB/s 19KB --- http://www.theitroad.local/ ping statistics -- 7 connects, 7 ok, 0.00% failed round-trip min/avg/max = 1507.7/1693.4/2620.3 ms Transfer speed: min/avg/max = 9/21/24 KB
测试远程服务器CPU
-B选项和-G选项一起要求HTTP服务器压缩返回的数据,这将减少连接带宽的影响,同时增加HTTP服务器的处理器能力的影响。
$ httping -BGg http://www.theitroad.local/
Flood网络服务器
ping的-f选项用于泛滥ping,即在每个ping之间不会闲置,而是以计算机和网络允许的ping速度(不要在生产服务器或者第三方服务器上运行此命令):
$ httping -fg http://www.theitroad.local/