Http 压测工具 wrk 基本使用
Http 压测工具 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,使用示例如下:
wrk -t 400 -c 4000 --timeout 10s -d 10s --latency http://localhost:12345/api/values
使用 docker
docker run --rm williamyeh/wrk -t 400 -c 4000 --timeout 10s -d 10s --latency http://localhost:12345/api/values
参数详解:
在 bash 中输入 wrk 即可获取到详细的参数说明:

-c, --connections(连接数): total number of HTTP connections to keep open with each thread handling N = connections/threads
-d, --duration(测试持续时间): duration of the test, e.g. 2s, 2m, 2h
-t, --threads(线程): total number of threads to use
-s, --script(脚本): LuaJIT script, see SCRIPTING
-H, --header(头信息): HTTP header to add to request, e.g. "User-Agent: wrk"
--latency(响应信息): print detailed latency statistics
--timeout(超时时间): record a timeout if a response is not received within this amount of time.
来对必应做一个测试
wrk -t8 -c200 -d30s --latency "http://www.bing.com"
输出:
Running 30s test @ http://www.bing.com
8 threads and 200 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 46.67ms 215.38ms 1.67s 95.59%
Req/Sec 7.91k 1.15k 10.26k 70.77%
Latency Distribution
50% 2.93ms
75% 3.78ms
90% 4.73ms
99% 1.35s
1790465 requests in 30.01s, 684.08MB read
Requests/sec: 59658.29
Transfer/sec: 22.79MB
结果分析:
Running 30s test @ http://www.bing.com (压测时间30s)
8 threads and 200 connections (共8个测试线程,200个连接)
Thread Stats Avg Stdev Max +/- Stdev
(平均值) (标准差)(最大值)(正负一个标准差所占比例)
Latency 46.67ms 215.38ms 1.67s 95.59%
(延迟)
Req/Sec 7.91k 1.15k 10.26k 70.77%
(处理中的请求数)
Latency Distribution (延迟分布)
50% 2.93ms
75% 3.78ms
90% 4.73ms
99% 1.35s (99分位的延迟)
1790465 requests in 30.01s, 684.08MB read (30.01秒内共处理完成了1790465个请求,读取了684.08MB数据)
Requests/sec: 59658.29 (平均每秒处理完成59658.29个请求)
Transfer/sec: 22.79MB (平均每秒读取数据22.79MB)
注:如果 url 不带 & 参数可以不需要加加引号,如: "url",但是如果有多个get参数有 &则需要加上双引号才能请求完整的地址,否则会把 & 后面的参数丢失。
Reference
- https://hub.docker.com/r/williamyeh/wrk/
- https://github.com/wg/wrk
- https://cloud.tencent.com/developer/article/1346649
- https://www.cnblogs.com/jiftle/p/7158291.html
Http 压测工具 wrk 基本使用的更多相关文章
- Http压测工具wrk使用指南【转】
用过了很多压测工具,却一直没找到中意的那款.最近试了wrk感觉不错,写下这份使用指南给自己备忘用,如果能帮到你,那也很好. 安装 wrk支持大多数类UNIX系统,不支持windows.需要操作系统支持 ...
- Http压测工具wrk使用指南
用过了很多压测工具,却一直没找到中意的那款.最近试了wrk感觉不错,写下这份使用指南给自己备忘用,如果能帮到你,那也很好. 安装 wrk支持大多数类UNIX系统,不支持windows.需要操作系统支持 ...
- http压测工具wrk使用
安装 wrk支持大多数类UNIX系统,不支持windows.需要操作系统支持LuaJIT和OpenSSL,不过不用担心,大多数类Unix系统都支持.安装wrk非常简单,只要从github上下载wrk源 ...
- nginx压测工具--wrk
基本使用 命令行敲下wrk,可以看到使用帮助 Usage: wrk <options> <url> Options: -c, --connections <N> C ...
- http压测工具wrk
安装 wrk支持大多数类UNIX系统,不支持windows.需要操作系统支持LuaJIT和OpenSSL,不过不用担心,大多数类Unix系统都支持.安装wrk非常简单,只要从github上下载wrk源 ...
- HTTP 压测工具wrk简介
前段时间项目压测,看到开发命令行下使用这个命令进行压测非常简洁.方便,萌发了学习的兴趣,这里仅做简单介绍. 安装 wrk支持大多数UNIX系统,不支持Windows.需要操作系统支持LuaJIT和Op ...
- 压测工具wrk的编译安装与基础使用
Linux上编译安装: [root@centos ~]# cd /usr/local/src [root@centos ~]# yum install git -y [root@centos ~]# ...
- 接口压测工具WRK的学习与使用
之前一直在使用jmeter,第一次接触wrk,记录下使用过程以便自己再次使用. 首先,WRK是linux系统上才可以使用的工具,我也不想剑走偏锋的去研究如何让wrk可以在windows系统上使用. 临 ...
- wrk压测工具使用
介绍分为四部分 1.wrk简述 2.wrk安装 3.wrk运行参数 4.wrk高级用法 1.wrk简述 当使用ab做压测的时候发现,ab的客户端消耗很大,而且测试时性能较差,测试redis,sprin ...
随机推荐
- [Swift]LeetCode81. 搜索旋转排序数组 II | Search in Rotated Sorted Array II
Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand. (i.e. ...
- [Swift]LeetCode323. 无向图中的连通区域的个数 $ Number of Connected Components in an Undirected Graph
Given n nodes labeled from 0 to n - 1 and a list of undirected edges (each edge is a pair of nodes), ...
- [Swift]LeetCode437. 路径总和 III | Path Sum III
You are given a binary tree in which each node contains an integer value. Find the number of paths t ...
- [Swift]LeetCode654. 最大二叉树 | Maximum Binary Tree
Given an integer array with no duplicates. A maximum tree building on this array is defined as follo ...
- [Swift]LeetCode853. 车队 | Car Fleet
N cars are going to the same destination along a one lane road. The destination is target miles awa ...
- 安装ubuntu18.10并连接xshell6
emmmm万万没想到上一篇装的linux内核才3.10,装个ubuntu系统来继续自己的docker学习之旅. 话不多说,先下镜像,地址:http://mirrors.melbourne.co.uk/ ...
- Python内置函数(55)——round
英文文档: round(number[, ndigits]) Return the floating point value number rounded to ndigits digits afte ...
- Redis的应用场景
最近做了个小项目是WebForm 做着做着发现前台的首页读取速度很慢,并且多个用户同时访问我的Sqlserver承受不住!之后就想到了Redis 代码如下: /// <summary> / ...
- Python高级特性(一)
一.切片 L = ['Michael', 'Sarah', 'Tracy', 'Bob', 'Jack']取出前三个元素 , 笨方法就是通过下标一个一个获取 [L[0], L[1], L[2]]Pyt ...
- 并发编程(五)——AbstractQueuedSynchronizer 之 ReentrantLock源码分析
本文将从 ReentrantLock 的公平锁源码出发,分析下 AbstractQueuedSynchronizer 这个类是怎么工作的,希望能给大家提供一些简单的帮助. AQS 结构 先来看看 AQ ...