{"id":34162348,"url":"https://github.com/fengf233/mmin","last_synced_at":"2025-12-15T09:01:13.761Z","repository":{"id":179408043,"uuid":"663413939","full_name":"fengf233/mmin","owner":"fengf233","description":"go实现的http性能压测工具,主要应对应用层设备的性能测试","archived":false,"fork":false,"pushed_at":"2025-04-25T08:55:52.000Z","size":4954,"stargazers_count":10,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-25T09:47:26.227Z","etag":null,"topics":["apachebench","load-testing","performance","performance-testing","plow","wrk"],"latest_commit_sha":null,"homepage":"","language":"HTML","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fengf233.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2023-07-07T08:32:41.000Z","updated_at":"2025-04-25T08:54:43.000Z","dependencies_parsed_at":null,"dependency_job_id":"eae6f0c6-58b6-46e4-8f42-4b9903b062a5","html_url":"https://github.com/fengf233/mmin","commit_stats":null,"previous_names":["fengf233/mmin"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/fengf233/mmin","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fengf233%2Fmmin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fengf233%2Fmmin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fengf233%2Fmmin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fengf233%2Fmmin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fengf233","download_url":"https://codeload.github.com/fengf233/mmin/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fengf233%2Fmmin/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":27748195,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-12-15T02:00:09.782Z","response_time":96,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["apachebench","load-testing","performance","performance-testing","plow","wrk"],"created_at":"2025-12-15T09:00:35.934Z","updated_at":"2025-12-15T09:01:13.755Z","avatar_url":"https://github.com/fengf233.png","language":"HTML","readme":"- [工具介绍](#工具介绍)\n- [快速使用](#快速使用)\n  - [命令行参数说明](#命令行参数说明)\n  - [结果说明](#结果说明)\n- [配置说明](#配置说明)\n- [测试案例](#测试案例)\n  - [QPS和吞吐](#qps和吞吐)\n  - [并发连接数](#并发连接数)\n  - [新建连接速率](#新建连接速率)\n  - [多用户并发](#多用户并发)\n- [免责声明](#免责声明)\n- [参考](#参考)\n\n---\n## 工具介绍\n\nmmin是一个go实现的基于TCP的压测工具，目的是为了模拟测试应用层设备（web服务器，waf，应用层防火墙）等性能，包括QPS/TPS，应用层吞吐，新建连接，并发连接等，得益于go的并发管理，可以充分运用客户端的资源。\n\n- 类似于jmeter线程组，可以在一个协程中发送多个HTTP请求\n- 支持远程控制多台设备一起压测\n\n以后可能支持:\n\n- http2.0\n- 基于国密的HTTPS测试\n- http变量替换\n\n\n\u003e 目前只支持http压测，但是容易拓展其他TCP私有协议\n\n\n## 快速使用\n```\n./mmin -u http://www.test.com/ -c 100 -t 20\n```\n\n\u003e 注意:当设置线程数过大时,需要查看进程文件句柄是否有限制,ulimit -n查看,如果-c大于ulimit -n,可能会报错open file too many\n\n### 命令行参数\n\n```shell\nUsage of ./mmin-mac-arm64:\n  -H value\n        自定义HTTP头 (可重复使用)\n  -X string\n        HTTP请求方法 (default \"GET\")\n  -c int\n        并发线程数 (default 100)\n  -conf string\n        配置文件路径 (yaml,json格式)\n  -d string\n        POST请求体数据\n  -k int\n        单个TCP连接最大请求数 (default 100)\n  -port string\n        服务器监听端口 (default \"8888\")\n  -r int\n        每秒请求数限制(0表示不限制)\n  -t int\n        运行时间(秒) (default 10)\n  -u string\n        目标URL (例如: http://example.com:8080/path)\n  -v    显示详细调试信息\n  -web\n        启动web服务\n```\n\n### 结果说明\n\n```shell\nCreat TCP conns Start:\nTime       ConnCount   \n---------- ------------\n1          92          \nCreat TCP conns: 100\n\nTime       Success      Rate         ReqTime      Send         Receive      Status              \n---------- ------------ ------------ ------------ ------------ ------------ --------------------\n1.0104218  8000         8000         10.916383    3.566506     52.043415    [200]:8000          \n2.0141416  15077        7077         12.503663    3.346634     49.08017     [200]:15077         \n3.075825   19722        4645         18.484386    2.8569558    41.97926     [200]:19722         \n4.077483   27194        7472         11.107747    2.9669635    43.638382    [200]:27194         \n5.0766826  35097        7903         10.674035    3.070042     45.195717    [200]:35097         \n6.081588   41899        6802         12.275972    3.0591137    45.05245     [200]:41899         \n7.0822926  50969        9070         10.218876    3.1936321    47.045       [200]:50969         \n8.082782   57933        6964         12.646858    3.178943     46.84416     [200]:57933         \n9.087093   65644        7711         11.287118    3.2038012    47.218437    [200]:65644         \n\nResult     Statistics                                                                           \n---------- -------------------------------------------------------------------------------------\nRunTime:   10.000029 s                                                                          \nSuccess:   75241                                                                                \nAvgRate:   7524.078125 Req/s                                                                    \nReqTime:   11.516679 ms                                                                         \nSend:      3.333734 Mbps                                                                        \nReceive:   49.140011 Mbps                                                                       \nStatus:    [200]:75241                                                                          \nReqTime Quantile: 50: 7.747041 75: 8.903125 90: 10.270083 95: 12.527833 99: 124.939167 \n```\n输出分为三个部分，第一个部分为创建TCP的结果，第二个部分为实时每秒的统计，第三个部分为总的统计结果\n```\nRunTime 运行时间\nSuccess 发送成功数量\nAvgRate 平均QPS\nReqTime 平均请求响应时间,从发送到响应的时间\nSend    发送的应用层吞吐Mbps\nReceive 接收的应用层吞吐Mbps\nStatus  响应码统计\nReqTime Quantile: 请求响应时间分位统计\n```\n\n## web服务\n启动web服务后，可以通过浏览器访问URL_ADDRESS启动web服务后，可以通过浏览器访问http://localhost:8888/\n```shell\n./mmin -web -port 8888\n```\n\n![web1图片描述](./web1.jpg)\n![web2图片描述](./web2.jpg)\n\n\n## 配置说明\n\n除了类似于ab的运行方式，还支持运行conf的方式，当使用-conf后，会根据指定的yaml运行压测，配置说明如下\n```yaml\nRunTime: 5                          #总体运行时间      \nDebug: False\n\nTcpGroups: \n- Name: group1           \n  MaxTcpConnPerIP: 10000            #每个源IP创建最大TCP连接数\n  SrcIP: [\"2.0.0.19\",\"2.0.0.100\" ]  #源IP,为[]表示使用默认IP\n  MaxQps: 500                       #发送http请求最大QPS \n  Dst: 2.0.0.67:80                  #TCP目的地址\n  ReqThread: 10                     #发送http请求的线程数\n  MaxReqest: 100                    #每个TCP连接最多发送多少连接\n  IsHttps: false                    #是否是https\n  SendHttp: [\"test1\"]               #每个TCP连接中循环发送的http请求\n\nParams:                             #定义参数,可以在HTTPConfs中使用\n- Name: aaa\n  Type: RandomInt\n  Spec: [1,10]\n- Name: bbb\n  Type: RandomStr\n  Spec: [10]\n\nHTTPConfs:                          #定义发送的http请求\n- Name: test1                       #http请求标志符\n  Proto: HTTP/1.1                   #http协议,HTTP/1.0,HTTP/1.1\n  Method: GET                       #请求方法\n  URI: http://2.0.0.67?a=0          #URL\n  Header: {                         #header,键值对方式\n    \"test\":\"faf\"\n  }\n  Body: \"\"                          #body内容,字符串方式\n  FileUpload: \"\"                    #文件上传,支持多文件上传,文件路径可以是相对路径,也可以是绝对路径\n  UseParams: [\"aaa\",\"bbb\"]          #使用参数,可以使用Params中定义的参数,支持多个\n\n```\n其他可选的TcpGroups参数如下\n```yaml\nTcpGroups:\n  ...\n  TcpCreatThread: 1                 #初始化创建TCP池的线程,一般为1就行,只是测大并发时可以调高\n  TcpConnThread: 10                 #循环生产TCP池的线程,就是当MaxReqest满足关闭TCP后,补充创建TCP的线程,长连接的情况设置ReqThread/MaxReqest就差不多了\n  TcpCreatRate: 0                   #初始化创建TCP的速率,0为不限制\n  WriteTimeout: 10                  #TCP写超时时间,单位秒\n  ReadTimeout: 10                   #TCP读超时时间,单位秒\n  ConnTimeout: 10                   #TCP连接超时时间,单位秒\n```\n\n命令运行方式\n```shell\n./mmin -conf test.yaml\n```\n\n\n## 测试案例\n\n### QPS和吞吐\n\nQPS表示每秒处理的HTTP请求数\n\n如果是单个请求,直接使用命令行执行就行\n\n```shell\n./mmin -u http://www.test.com/ -c 100 -t 20\n```\n-c对应ReqThread（发送http请求的线程数），越大压测力度越大\n\n使用配置的方式\n\n```yaml\nRunTime: 20                                    \nDebug: false\n\nTcpGroups: \n- Name: group1                      \n  MaxTcpConnPerIP: 1000      #由于测试qps,一般是长连接,所以tcp可以不用设置太多,比ReqThread多一点就行     \n  SrcIP: []                  #源ip默认就行\n  MaxQps: 0                  #设置0不限速,如果需要测试被压测机在某个QPS下的情况,可以设置限速                \n  Dst: 2.0.0.67:80           #TCP目的地址,只支持ip         \n  ReqThread: 1000            #请求线程, 越大压测力度越大                   \n  MaxReqest: 100             #nginx默认长连接发送100个就会自动断开,一般默认100                    \n  IsHttps: false             #不是https                   \n  SendHttp: [\"test1\"]        #发送的http   \n\nHTTPConfs:\n- Name: test2\n  Proto: HTTP/1.1\n  Method: POST\n  URI: http://2.0.0.67?a=1\n  Header: {\n    \"test\":\"faf\"\n  }\n  Body: \"a=b\u0026\u0026b=c\"\n\n```\n然后\n```\n./mmin -conf test.yaml\n```\n\n### 并发连接数\n\n并发连接数主要是测试在创建几百万的TCP连接下，以一个新建速率发送HTTP请求，达到边建边拆，维持几百万的TCP连接，与一般的并发测试不同\n\n要达到几百万的TCP连接，需要修改设置一些系统参数，如下\n\n```\nfs.nr_open                        #进程最大文件数\nfs.file-max                       #系统最大文件数\nnofile（soft 和 hard）ulimit –n    #进程最大文件数\n#soft nofile 可以按用户来配置，而 fs.nr_open 所有用户只能配一个\nnet.ipv4.ip_local_port_range      #端口范围\n```\n一般来说，这样配置就行，推荐文章：https://mp.weixin.qq.com/s/GBn94vdL4xUL80WYrGdUWQ?from_wecom=1\n```\n# vi /etc/sysctl.conf\nfs.nr_open=1100000  //要比 hard nofile 大一点\nfs.file-max=1100000 //多留点buffer\n# sysctl -p\n# vi /etc/security/limits.conf\n*  soft  nofile  1000000\n*  hard  nofile  1000000\n```\n实测每个mmin进程最多70w个连接，多了就连接上不去了，所以建议多开几个窗口运行-S模式来并发几百万的连接\n\nnginx需要设置\nworker_connections 每个work可以建立的连接数\n由于客户端会等待发送，需要设置nginx超时时间\nclient_body_timeout  500;\nclient_header_timeout  500;\nsend_timeout  500;\n测试配置\n\n```yaml\nRunTime: 20                                    \n\nTcpGroups: \n- Name: group1                      \n  MaxTcpConnPerIP: 50000      #每个srcip的TCP连接数,10个srcip就是50w\n  TcpCreatThread: 10          #由于tcp较多,初始化50w个tcp可以调高一些   \n  TcpConnThread: 10           #由于以MaxQps去边建边拆维持tcp连接，所以可以适当调高一点      \n  TcpCreatRate: 100000        #50w个tcp,可以限制一定速率         \n  SrcIP: [                    #源ip要10个，需要自己先把网卡的ip设置上,ip addr add 2.0.0.1/24 dev eth1\n\"2.0.0.1\",\"2.0.0.2\"..\"2.0.0.10\"\n  ]                  \n  MaxQps: 10000               #以10000的速率维持               \n  Dst: 2.0.0.67:80            #TCP目的地址,只支持ip         \n  ReqThread: 100              #10000的速率100个够了                  \n  MaxReqest: 1                #由于需要边建边拆，所以发送1个http请求就断开tcp                  \n  IsHttps: false              #不是https                   \n  SendHttp: [\"test1\"]         #发送的http   \n- Name: group2                #类似group1,不过srcip建议分开\n...\nHTTPConfs:\n- Name: test2\n  Proto: HTTP/1.0             #设置http1.0,使服务端断开\n  Method: GET\n  URI: http://2.0.0.67\n  Header: {\n    \"Connection\":\"close\"      #或者设置close，使服务端断开连接\n  }\n  Body: \"\"\n```\n多开几个窗口运行\n```shell\n./mmin -conf test.yaml\n```\n\n### 新建连接速率\n\nTCP新建速率是衡量被测设备处理TCP建连断连的速率，对于应用层设备，新建连接速率也需要处理http请求，即每个tcp发送一个http请求就断开\n\n配置如下:\n```yaml\nRunTime: 20                                    \nDebug: false\n\nTcpGroups: \n- Name: group1                      \n  MaxTcpConnPerIP: 10000      #每个srcip的TCP连接数,新建连接就是不断建不断拆,这里总连接数可以与预估新建速率相仿,比如新建速率大概5w,有5个srcip,每个ip就10000  \n  SrcIP: []                   \n  MaxQps: 50000               #预计50000的新建               \n  Dst: 2.0.0.67:80            #TCP目的地址,只支持ip         \n  ReqThread: 1000             #速率上不去可以调高                \n  MaxReqest: 1                #由于需要边建边拆，所以发送1个http请求就断开tcp                  \n  IsHttps: false              #不是https                   \n  SendHttp: [\"test1\"]         #发送的http   \n\nHTTPConfs:\n- Name: test2\n  Proto: HTTP/1.0             #设置http1.0,使服务端断开\n  Method: GET\n  URI: http://2.0.0.67\n  Header: {\n    \"Connection\":\"close\"      #或者设置close，使服务端断开连接\n  }\n  Body: \"\"\n```\n\n### 多用户并发\n\n也可以测试多用户并发的场景,比如5w个用户并发\n\n```yaml\nRunTime: 20                                    \nDebug: false\n\nTcpGroups: \n- Name: group1                      \n  MaxTcpConnPerIP: 50000     #5w个用户并发,可能需要5w个TCP\n  TcpConnThread: 1000        #可以调高一些      \n  SrcIP: []                  #源ip默认就行,不够可以加ip\n  MaxQps: 0                  #设置0不限速,如果需要测试被压测机在某个QPS下的情况,可以设置限速                \n  Dst: 2.0.0.67:80           #TCP目的地址,只支持ip         \n  ReqThread: 50000           #模拟5w个用户                  \n  MaxReqest: 100             #nginx默认长连接发送100个就会自动断开,一般默认100                    \n  IsHttps: false             #不是https                   \n  SendHttp: [\"test1\"]        #发送的http   \n\nHTTPConfs:\n- Name: test2\n  Proto: HTTP/1.1\n  Method: POST\n  URI: http://2.0.0.67?a=1\n  Header: {\n    \"test\":\"faf\"\n  }\n  Body: \"a=b\u0026\u0026b=c\"\n\n```\n\n## 免责声明\n本项目仅用于学习测试，请勿利用文章内的相关工具与技术从事非法测试，如因此产生的一切不良后果与本项目无关，用户承担因使用此工具而导致的所有法律和相关责任！作者不承担任何法律责任！\n\n\n## 参考\n\nhttps://github.com/link1st/go-stress-testing\n\nhttps://github.com/six-ddc/plow","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffengf233%2Fmmin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffengf233%2Fmmin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffengf233%2Fmmin/lists"}