压测工具总结——Webbench、go-stress-testing-《GO开发知识笔记》

admin 2025-11-04 01:13:23 编程 来源:ZONE.CI 全球网 0 阅读模式
  • 一、Webbench
    • 安装
    • 简单使用
  • 二、go-stress-testing
    • 安装
    • 简单使用

    一、Webbench

    Webbench最多可以模拟3万个并发连接去测试网站的负载能力。

    安装

    wget wget http://www.ha97.com/code/webbench-1.5.tar.gz tar xf webbench-1.5.tar.gz make && make install 异常:cc -Wall -ggdb -W -O -c -o webbench.o webbench.c webbench.c: In function ‘alarm_handler’: webbench.c:77:31: warning: unused parameter ‘signal’ [-Wunused-parameter] static void alarm_handler(int signal) ^ cc -Wall -ggdb -W -O -o webbench webbench.o ctags .c /bin/sh: ctags: command not found make: [tags] Error 127 (ignored) install -s webbench /usr/local/bin install -m 644 webbench.1 /usr/local/man/man1 install: cannot create regular file ‘/usr/local/man/man1’: No such file or directory make: ** [install] Error 1解决:新建 /usr/local/man/ 目录

    简单使用

    webbench -c 300 -t 60 http://www.baidu.com/ 注意:仅支持http协议,不支持https等;-c表示并发数-t表示运行测试URL的时间(秒)webbench 压力测试软件www.jianshu.com/p/dc1032b19c8d

    二、go-stress-testing

    go-stress-testing 是go语言实现的简单压测工具,源码开源、支持二次开发,可以压测http、webSocket请求、私有rpc调用,使用协程模拟单个用户,可以更高效的利用CPU资源。

    安装

    下载地址:https://github.com/link1st/go-stress-testing/releases以linux版本为例:wget https://github.com/link1st/go-stress-testing/releases/download/v0.1.3/go-stress-testing-linux chmod 766 go-stress-testing-linux

    简单使用

    ./go-stress-testing-linux -c 5 -n 2 -u https://www.baidu.com/支持参数:Usage of ./go-stress-testing-mac: -c uint 并发数 (default 1) -n uint 请求数(单个并发/协程) (default 1) -u string 压测地址 -d string 调试模式 (default “false”) -H value 自定义头信息传递给服务器 示例:-H ‘Content-Type: application/json’ -data string HTTP POST方式传送数据 -v string 验证方法 http 支持:statusCode、json webSocket支持:json -p string curl文件路径结果:─────┬───────┬───────┬───────┬────────┬────────┬────────┬────────┬──────── 耗时│ 并发数 │ 成功数│ 失败数 │ qps │最长耗时 │最短耗时│平均耗时 │ 错误码 ─────┼───────┼───────┼───────┼────────┼────────┼────────┼────────┼──────── 1s│ 1│ 8│ 0│ 8.09│ 133.16│ 110.98│ 123.56│200:8 2s│ 1│ 15│ 0│ 8.02│ 138.74│ 110.98│ 124.61│200:15 3s│ 1│ 23│ 0│ 7.80│ 220.43│ 110.98│ 128.18│200:23 4s│ 1│ 31│ 0│ 7.83│ 220.43│ 110.23│ 127.67│200:31 5s│ 1│ 39│ 0│ 7.81│ 220.43│ 110.23│ 128.03│200:39 6s│ 1│ 46│ 0│ 7.72│ 220.43│ 110.23│ 129.59│200:46 7s│ 1│ 54│ 0│ 7.79│ 220.43│ 110.23│ 128.42│200:54 8s│ 1│ 62│ 0│ 7.81│ 220.43│ 110.23│ 128.09│200:62 9s│ 1│ 70│ 0│ 7.79│ 220.43│ 110.23│ 128.33│200:70 10s│ 1│ 78│ 0│ 7.82│ 220.43│ 106.47│ 127.85│200:78 11s│ 1│ 84│ 0│ 7.64│ 371.02│ 106.47│ 130.96│200:84 12s│ 1│ 91│ 0│ 7.63│ 371.02│ 106.47│ 131.02│200:91 13s│ 1│ 99│ 0│ 7.66│ 371.02│ 106.47│ 130.54│200:99 13s│ 1│ 100│ 0│ 7.66│ 371.02│ 106.47│ 130.52│200:100 * 结果 stat ** 处理协程数量: 1 请求总数: 100 总请求时间: 13.055 秒 successNum: 100 failureNum: 0 * 结果 end **

    以太坊cppgolang区别 编程

    以太坊cppgolang区别

    以太坊是一种去中心化的开源平台,它采用智能合约技术,旨在构建和运行不受干扰的分布式应用程序。作为目前最受欢迎的区块链平台之一,以太坊提供了多种编程语言的支持,其
    progolang 编程

    progolang

    Go语言(Golang)是由Google开发的一门静态类型编程语言。作为一名专业的Golang开发者,我深知这门语言的优势和特点。在本文中,我将介绍Golang
    golangn个发送者 编程

    golangn个发送者

    Golang是一种开源的编程语言,由Google团队开发,旨在提高程序的并发性和简化软件开发过程。在Go语言中,有时需要向多个接收者发送信息。本文将介绍如何在G
    golang技能图谱 编程

    golang技能图谱

    从互联网行业的快速发展到人工智能技术的日益成熟,各种编程语言也应运而生。而在这众多的编程语言中,Golang(即Go)作为一门强大且高效的开发语言备受关注。Go
    评论:0   参与:  11