{"id":13626201,"url":"https://github.com/youzan/gatling-dubbo","last_synced_at":"2025-10-04T14:56:09.279Z","repository":{"id":81153856,"uuid":"162019091","full_name":"youzan/gatling-dubbo","owner":"youzan","description":"A gatling plugin for running load tests on Apache Dubbo(https://github.com/apache/incubator-dubbo) and other java ecosystem.","archived":false,"fork":false,"pushed_at":"2019-08-20T08:45:41.000Z","size":445,"stargazers_count":151,"open_issues_count":4,"forks_count":43,"subscribers_count":25,"default_branch":"master","last_synced_at":"2025-06-15T16:45:38.573Z","etag":null,"topics":["benchmark","benchmarking","dubbo","gatling","gatling-dubbo","java","load-testing","loadtest","performance","performance-testing","scala","stress-testing"],"latest_commit_sha":null,"homepage":"","language":"Scala","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/youzan.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2018-12-16T16:20:20.000Z","updated_at":"2025-06-09T07:02:57.000Z","dependencies_parsed_at":null,"dependency_job_id":"7eeed40e-0ab0-437e-995f-f23f97b3d5a5","html_url":"https://github.com/youzan/gatling-dubbo","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/youzan/gatling-dubbo","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/youzan%2Fgatling-dubbo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/youzan%2Fgatling-dubbo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/youzan%2Fgatling-dubbo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/youzan%2Fgatling-dubbo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/youzan","download_url":"https://codeload.github.com/youzan/gatling-dubbo/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/youzan%2Fgatling-dubbo/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278328167,"owners_count":25968900,"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-10-04T02:00:05.491Z","response_time":63,"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":["benchmark","benchmarking","dubbo","gatling","gatling-dubbo","java","load-testing","loadtest","performance","performance-testing","scala","stress-testing"],"created_at":"2024-08-01T21:02:12.779Z","updated_at":"2025-10-04T14:56:09.260Z","avatar_url":"https://github.com/youzan.png","language":"Scala","funding_links":[],"categories":["Scala","Tools"],"sub_categories":["Plugins"],"readme":"# Gatling-Dubbo 2.0\n`【招聘】Java开发、测试开发等岗位，有意者请将简历投递至\u003ccanyuns【@】163.com\u003e`  \n\nGatling的非官方Dubbo压测插件，基于Gatling 2.3.1，插件已在Dubbo 2.6.5上测试，但理论上所有Dubbo版本都适用，`2.0插件采用普通API调用方式执行压测请求，如果你想使用泛化调用方式执行压测请求，请参考`[1.0插件](https://github.com/youzan/gatling-dubbo/tree/v1.0)`，推荐使用2.0插件，即采用普通API调用方式，因为 dubbo 官方推荐生产上使用该方式，所以以同样的方式压测得到的结果，更具有参考意义，且2.0插件无需 dubbo 框架做任何改造。`\n\n\u003e 区别于 Gatling-Dubbo 1.0 只支持 dubbo 压测，Gatling-Dubbo 2.0 不仅支持 dubbo 压测，还支持非 dubbo 的其他 java 调用压测，因为脚本中的 `f` 怎么写控制权在你手里，就像使用 Jmeter 压测 java 一样。\n\n## 使用方法\n\n### 打包Jar\n\n\u003e 按需修改配置:  \n- 默认为4核8G内存机器配置了200线程池，与dubbo线程池一致，你也可以根据自己的机器配置使用API调整线程池大小，下述\n- 如果你使用其他Dubbo版本，请修改根目录下build.sbt中的libraryDependencies配置\n\n\u003e 如果你不需要修改配置，可以略过以下打包步骤，直接[下载Jar包（该  Jar 包无应用依赖）](https://github.com/youzan/gatling-dubbo/releases)\n\n项目依赖sbt，请安装sbt 1.2.1，详见[官方文档](https://www.scala-sbt.org/1.x/docs/Setup.html)，执行\n```bash\n$ git clone https://github.com/youzan/gatling-dubbo.git\n$ cd gatling-dubbo\n$ sbt assembly\n```\n\n### 将上述jar包拷贝到/your-path-to/gatling-charts-highcharts-bundle-2.3.1/lib目录\n```bash\n$ cp /your-path-to/gatling-dubbo/target/scala-2.12/gatling-dubbo-assembly-1.0.jar /your-path-to/gatling-charts-highcharts-bundle-2.3.1/lib\n```\n\n### 依赖\n由于插件采用普通API调用方式执行压测请求，所以需要引入服务特定的 API 包，为了演示方便，这里直接将依赖写在了项目根目录下的 build.sbt 中：\n```sbtshell\nname := \"gatling-dubbo\"\n\nversion := \"1.0\"\n\nscalaVersion := \"2.12.6\"\n\nlibraryDependencies ++= Seq(\n  \"io.gatling\" % \"gatling-core\" % \"2.3.1\" % \"provided\",\n  \"com.alibaba\" % \"dubbo\" % \"2.6.5\",\n  \"com.youzan.xxx\" % \"xxx-api\" % \"1.xxx-RELEASE\" exclude(\"ch.qos.logback\", \"logback-classic\") //应用 API 包\n)\n\nassemblyOption in assembly := (assemblyOption in assembly).value.copy(includeScala = false)\n```\n\n### 创建Simulation和相应的json数据文件\n参考gatling-dubbo/src/test/scala目录下的DubboTest.scala和data.json\n\n`DubboTest.scala`具体说明请参考示例\n\n\u003e check 说明  \n目前 check 支持两种，jsonPath 和 custom，如果 dubbo 返回值可以转化为 json（如 PlainResult、Map 等），则推荐使用 jsonPath 校验结果，如果 dubbo 返回值是 String 等类型，则推荐使用 custom 校验结果，即自定义校验逻辑，custom 的示例如下：  \n```scala\n.check(custom((response: String) =\u003e {\n              print(response)\n              response == \"expected response\"\n            }, \"option error message\"))\n```\n\n\u003e 示例中展示的是单接口的例子，如果你想探测应用单机的真实水位，可以结合使用 gatling 的 randomSwitch 混合多接口且按生产环境真实的接口比例同时进行压测。  \n\n`data.json`\n```json\n[\n  {\n    \"kdtId\": 160,\n    \"page\": 1\n  },\n  {\n    \"kdtId\": 160,\n    \"page\": 2\n  },\n  {\n    \"kdtId\": 160,\n    \"page\": 3\n  }\n]\n```\n数据采用 json 数组保存，其中每一个 json 对象都是一次压测请求需要的完整参数，且为了方便通过 session 设置动态参数，数据结构采用一维结构，风格同 Jmeter。\n\n### 执行Dubbo压测\n```bash\n$ bin/gatling.sh\nGATLING_HOME is set to /your-path-to/gatling-charts-highcharts-bundle-2.3.1\nChoose a simulation number:\n     [0] dubbo.DubboTest\n0\nSelect simulation id (default is 'dubbotest'). Accepted characters are a-z, A-Z, 0-9, - and _\n\nSelect run description (optional)\n\nSimulation dubbo.DubboTest started...\n\n================================================================================\n2019-04-04 10:12:44                                           5s elapsed\n---- Requests ------------------------------------------------------------------\n\u003e Global                                                   (OK=56     KO=0     )\n\u003e com.youzan.xxx.XxxService                                (OK=56     KO=0     )\n\n---- scenario of xxx -----------------------------------------------------------\n[--------------------------------------------------------------------------]  0%\n          waiting: 0      / active: 10     / done:0\n================================================================================\n\n...\n\n================================================================================\n2019-04-04 10:13:11                                          31s elapsed\n---- Requests ------------------------------------------------------------------\n\u003e Global                                                   (OK=320    KO=0     )\n\u003e com.youzan.xxx.XxxService                                (OK=320    KO=0     )\n\n---- scenario of xxx -----------------------------------------------------------\n[--------------------------------------------------------------------------]  0%\n          waiting: 0      / active: 10     / done:0\n================================================================================\n\nSimulation dubbo.DubboTest completed in 31 seconds\nParsing log file(s)...\nParsing log file(s) done\nGenerating reports...\n\n================================================================================\n---- Global Information --------------------------------------------------------\n\u003e request count                                        320 (OK=320    KO=0     )\n\u003e min response time                                     44 (OK=44     KO=-     )\n\u003e max response time                                    343 (OK=343    KO=-     )\n\u003e mean response time                                    62 (OK=62     KO=-     )\n\u003e std deviation                                         42 (OK=42     KO=-     )\n\u003e response time 50th percentile                         49 (OK=49     KO=-     )\n\u003e response time 75th percentile                         53 (OK=53     KO=-     )\n\u003e response time 95th percentile                        160 (OK=160    KO=-     )\n\u003e response time 99th percentile                        275 (OK=275    KO=-     )\n\u003e mean requests/sec                                 10.323 (OK=10.323 KO=-     )\n---- Response Time Distribution ------------------------------------------------\n\u003e t \u003c 800 ms                                           320 (100%)\n\u003e 800 ms \u003c t \u003c 1200 ms                                   0 (  0%)\n\u003e t \u003e 1200 ms                                            0 (  0%)\n\u003e failed                                                 0 (  0%)\n================================================================================\n\nReports generated in 0s.\nPlease open the following file: /your-path-to/gatling-charts-highcharts-bundle-2.3.1/results/dubbotest-1554343959840/index.html\n```\n\n打开上述报告查看更多压测信息：\n![Reports](png/Reports.png)\n\n## gatling-dubbo 在有赞的应用示例\nI 应用基线性能评估与容量规划：\n![Reports](png/example-1.png)  \n\nII 中心化限流效果验证：\n![Reports](png/example-2.png)\n\n## License\nApache License, Version 2.0\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyouzan%2Fgatling-dubbo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyouzan%2Fgatling-dubbo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyouzan%2Fgatling-dubbo/lists"}