原创文章,转载请注明: 转载自系统技术非业余研究

本文链接地址: qperf测量网络带宽和延迟

我们在做网络服务器的时候,通常会很关心网络的带宽和延迟。因为我们的很多协议都是request-reponse协议,延迟决定了最大的QPS,而带宽决定了最大的负荷。 通常我们知道自己的网卡是什么型号,交换机什么型号,主机之间的物理距离是多少,理论上是知道带宽和延迟是多少的。但是现实的情况是,真正的带宽和延迟情况会有很多变数的,比如说网卡驱动,交换机跳数,丢包率,协议栈配置,光实际速度都很大的影响了数值的估算。 所以我们需要找到工具来实际测量下。

网络测量的工具有很多,netperf什么的都很不错。 我这里推荐了qperf,这是RHEL 6发行版里面自带的,所以使用起来很方便,只要简单的:

yum install qperf

就好。

我们看下man qperf的介绍:

qperf measures bandwidth and latency between two nodes. It can work over TCP/IP as well as the RDMA transports. On one of the nodes, qperf is typically run with no arguments designating it the server node. One may then run qperf on a client node to obtain measurements such as bandwidth, latency and cpu utilization.
In its most basic form, qperf is run on one node in server mode by invoking it with no arguments. On the other node, it is run with two arguments: the name of the server node followed by the name of the test. A list of tests can be found in the section, TESTS. A variety of options may also be specified.

使用起来也相当简单:

在其中一台机器上运行qperf,不带任何参数就好,这台机器就充当服务器角色:

uname -r
2.6.32-131.21.1.tb477.el6.x86_64
$ qperf

在另外一台机器上运行qperf,测量tcp的带宽和延时,顺便看下双方机器的配置情况:

$ qperf 10.232.64.yyy tcp_bw tcp_lat conf
tcp_bw:
    bw  =  118 MB/sec
tcp_lat:
    latency  =  31.9 us
conf:
    loc_node   =  xxx.sqa.cm4
    loc_cpu    =  16 Cores: Intel Xeon  L5630 @ 2.13GHz
    loc_os     =  Linux 2.6.32-131.21.1.tb477.el6.x86_64
    loc_qperf  =  0.4.6
    rem_node   =  yyy.sqa.cm4
    rem_cpu    =  16 Cores: Intel Xeon  L5630 @ 2.13GHz
    rem_os     =  Linux 2.6.32-131.21.1.tb477.el6.x86_64
    rem_qperf  =  0.4.6

是不是很方便?典型情况下我们的带宽是118M,延迟是32us, 在标准的千M环境下是符合预期的。

当然qperf有很多高级参数,可以设置socket buffer的大小,绑定CPU亲缘性等, 很赞的一个特性是可以通过持续改变某个重要参数的值,来观察临界点:

-oo, –loop Var:Init:Last:Incr
Run a test multiple times sequencing through a series of values. Var is the loop variable;
Init is the initial value; Last is the value it must not exceed and Incr is the increment. It
is useful to set the –verbose_used (-vu) option in conjunction with this option.

比如我们可以透过改变消息的大小(msg_size),比如从1个字节到64K,每次倍增的方式,来观察带宽和延迟的变化情况,演示下:

$ qperf -oo msg_size:1:64K:*2  10.232.64.yyy tcp_bw tcp_lat
tcp_bw:
    bw  =  2.43 MB/sec
tcp_bw:
    bw  =  4.69 MB/sec
tcp_bw:
    bw  =  9.12 MB/sec
tcp_bw:
    bw  =  18.5 MB/sec
tcp_bw:
    bw  =  33.1 MB/sec
tcp_bw:
    bw  =  61.4 MB/sec
tcp_bw:
    bw  =  114 MB/sec
tcp_bw:
    bw  =  118 MB/sec
tcp_bw:
    bw  =  113 MB/sec
tcp_bw:
    bw  =  114 MB/sec
tcp_bw:
    bw  =  114 MB/sec
tcp_bw:
    bw  =  118 MB/sec
tcp_bw:
    bw  =  117 MB/sec
tcp_bw:
    bw  =  118 MB/sec
tcp_bw:
    bw  =  118 MB/sec
tcp_bw:
    bw  =  117 MB/sec
tcp_bw:
    bw  =  117 MB/sec
tcp_lat:
    latency  =  31 us
tcp_lat:
    latency  =  31.1 us
tcp_lat:
    latency  =  31.1 us
tcp_lat:
    latency  =  31.4 us
tcp_lat:
    latency  =  30.8 us
tcp_lat:
    latency  =  32.1 us
tcp_lat:
    latency  =  32.6 us
tcp_lat:
    latency  =  33.3 us
tcp_lat:
    latency  =  35.5 us
tcp_lat:
    latency  =  38.6 us
tcp_lat:
    latency  =  50.1 us
tcp_lat:
    latency  =  69.6 us
tcp_lat:
    latency  =  88 us
tcp_lat:
    latency  =  128 us
tcp_lat:
    latency  =  209 us
tcp_lat:
    latency  =  365 us
tcp_lat:
    latency  =  650 us


我们可以看到当包的大小达到64字节的时候,带宽就上不去了;包到达1K的时候,延迟有了很大的变化。 这些临界点对我们的服务器编程时候对性能的估计和预期非常有帮助。

qperf除了测量tcp的,还可以测试rdma, udp, sctp等主流网络协议的带宽和延迟,算是个很新的工具,推荐大家使用。

祝玩得开心!

qperf测量网络带宽和延迟的更多相关文章

  1. 如何使用qperf来衡量网络带宽和延迟性能?

    解析度 安装 qperf从RHEL服务器通道安装: 生的 # yum install qperf 检查带宽 服务器 让一个系统监听服务器: 生的 server # qperf 服务器默认在TCP端口1 ...

  2. 树莓派使用iperf3测量网络带宽

    这个工具需要两台设备都安装iperf3工具,一台作为服务端,一台作为客户端.客户端通过链接服务端测量吞吐量. 安装iperf3 sudo apt install iperf3 开启服务端 假设在一台I ...

  3. 网络带宽和速度测试windows和linux用iperf工具

    网络带宽和速度测试windows和linux用iperf工具   Iperf是一个网络性能测试工具.Iperf可以测试TCP和UDP带宽质量.Iperf可以测量最大TCP带宽,具有多种参数和UDP特性 ...

  4. RTMP服务器的延迟,多级边缘不影响延迟,gop为最大因素

    转自:http://blog.chinaunix.net/uid-26000296-id-4932826.html 编码器用FMLE,用手机秒表作为延迟计算. 结论: 1. 影响延迟的三个重要因素:网 ...

  5. 网络性能测试工具iperf详细使用图文教程

      Iperf是一个网络性能测试工具.Iperf可以测试TCP和UDP带宽质量.Iperf可以测量最大TCP带宽,具有多种参数和UDP特性. Iperf可以报告带宽,延迟抖动和数据包丢失.利用Iper ...

  6. 网络性能测试工具iperf详细使用图文教程【转载】

    原文:http://blog.163.com/hlz_2599/blog/static/142378474201341341339314/ 参考:http://man.linuxde.net/iper ...

  7. Python 全栈开发 -- 监控篇

    如果你已经玩转了 Python 编程语言语法,肯定想用这些知识,开发一款应用程序,它可以是在网上,可以炫耀或出售,那就需要全栈式开发 Python.具体如何创建,部署和运行生产 Python Web ...

  8. [转]网络性能评估工具Iperf详解(可测丢包率)

    原文链接:安全运维之:网络性能评估工具Iperf详解:http://os.51cto.com/art/201410/454889.htm 参考博文:http://linoxide.com/monito ...

  9. 网络性能测试工具Iperf/Jperf解读

    Iperf 是一个网络性能测试工具.Iperf 可以测试TCP 和UDP 带宽质量.Iperf 可以测量最大TCP 带宽,具有多种参数和UDP 特性. Iperf 可以报告带宽,延时抖动和数据包丢失. ...

随机推荐

  1. [leetcode]Plus One @ Python

    原题地址:https://oj.leetcode.com/problems/plus-one/ 题意: Given a non-negative number represented as an ar ...

  2. Linux上安装Hadoop集群(CentOS7+hadoop-2.8.0)

    1下载hadoop 2安装3个虚拟机并实现ssh免密码登录 2.1安装3个机器 2.2检查机器名称 2.3修改/etc/hosts文件 2.4 给3个机器生成秘钥文件 2.5 在hserver1上创建 ...

  3. Laravel validate 500异常 添加手机验证,中文验证与Validator验证的“半个”生命周期

    今天来讲一下,Lumen的Validator函数 1 2 3 4 5 6 7 8 9 10 11 use Validator;   ...   Class .. {   public function ...

  4. tensoflow数据读取

    数据读取 TensorFlow程序读取数据一共有3种方法: 供给数据(Feeding): 在TensorFlow程序运行的每一步, 让Python代码来供给数据. 从文件读取数据: 在TensorFl ...

  5. 【R】函数-字符处理函数

  6. Android LazyList 从网络获取图片并缓存

    原演示地址 本文内容 环境 演示 LazyList 从网络获取图片并缓存 参考资料 本文是 Github 上的一个演示,通过网络获取歌手专辑的缩略图,并显示在 ListView 控件中.该演示具备将缩 ...

  7. 【树莓派】Squid代理以及白名单配置

    Squid安装: sudo apt-get install squid3 -y 首先,建议备份一下这个配置文件,以免配错之后,无法恢复,又得重新安装: sudo cp /etc/squid3/squi ...

  8. css规范 - bem

    用我的话简述来说,即 B:何种元素 E:何种模块使用它(header,footer)等 M:描述它是做何种事情的 例如就是我有个主页,名称是:index.html index_header_logo ...

  9. 使用Swashbuckle.AspNetCore生成.NetCore WEBAPI的接口文档

    一.问题 使用Swashbuckle.AspNetCore生成.NetCore WEBAPI的接口文档的方法 二.解决方案 参考文章:https://docs.microsoft.com/zh-cn/ ...

  10. 1004: 不明飞行物(ufo)

    #include <iostream> #include <iomanip> #include <cstdlib> #include <string> ...