34.9k star,推荐一款使用工具,wrk
1 简介
wrk,一款http协议的压测工具,能够在单个多核 CPU 上运行时产生大量负载。它将多线程设计与可扩展的事件通知系统(如 epoll 和 kqueue)相结合。
高级功能可以通过lua脚本完成,可选的 LuaJIT 脚本可以执行 HTTP 请求生成、响应处理和自定义报告。
2 安装
github可以访问的直接到如下链接去下载就可以,目前支持linux
github如果无法访问的话,可以后台直接私信
3 示例:
这将运行基准测试30秒,使用12个线程,并保持400个HTTP连接打开。
返回结果:
命令参数:
4 注意项
运行 wrk 的机器必须具有足够数量的临时端口,并且应快速回收关闭的套接字。为了处理初始连接突发,服务器的侦听(2)积压工作应该大于正在测试的并发连接数。
仅更改 HTTP 方法、路径、添加标头或正文的用户脚本不会影响性能。每个请求的操作,特别是构建新的 HTTP 请求,以及使用 response() 必然会减少可以生成的负载量。
注:如需转载,须保留文首公众号名片,其它行为一律视为非授权转载。