9

Http benchmarking 工具 wrk 基本使用

 5 years ago
source link: http://mp.weixin.qq.com/s?__biz=MzAwNTMxMzg1MA%3D%3D&%3Bmid=2654077012&%3Bidx=6&%3Bsn=3f0c7134299bb939ecd1fc34afa5f206
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Http benchmarking 工具 wrk 基本使用

Intro

wrk 是一款现代HTTP基准测试工具,能够在单个多核CPU上运行时产生显着负载。它将多线程设计与可扩展事件通知系统(如epoll和kqueue)结合在一起。

官方描述:

wrk is a modern HTTP benchmarking tool capable of generating significant load when run on a single multi-core CPU. It combines a multithreaded design with scalable event notification systems such as epoll and kqueue.
An optional LuaJIT script can perform HTTP request generation, response processing, and custom reporting. Details are available in SCRIPTING and several examples are located in scripts/.

wrk 使用了 epoll,使得可以通过较少的线程来实现较多的连接,而用 ab 测试的时候就会发现很难达到特别高的并发,而 wrk 则利用 i/o 复用来实现较少的线程达到较高的并发。

Install

wrk支持大多数类UNIX系统,不支持windows。需要操作系统支持 LuaJIT 和 OpenSSL,不过不用担心,大多数类Unix系统都支持。安装wrk非常简单,只要从github上下载wrk源码,在项目路径下执行 make 命令即可。

在 win10 bash 上安装参考 :https://www.cnblogs.com/savorboard/p/wrk.html直接在 linux 上安装参考:https://www.cnblogs.com/jiftle/p/7158291.html

不想安装也可以直接使用 docker ,参考 williamyeh/wrk

Use

  • 直接使用安装的 wrk,使用示例如下:

  • 使用 docker

参数详解:

在 bash 中输入 wrk 即可获取到详细的参数说明:

QFfqYnE.png!web

来对必应做一个测试

输出:

结果分析:

注:如果 url 不带 & 参数可以不需要加加引号,如:"url",但是如果有多个get参数有 & 则需要加上双引号才能请求完整的地址,否则会把 & 后面的参数丢失。

Reference

  • https://hub.docker.com/r/williamyeh/wrk/

  • https://github.com/wg/wrk

  • https://cloud.tencent.com/developer/article/1346649


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK