• Stars
    star
    149
  • Rank 248,619 (Top 5 %)
  • Language
    Scala
  • Created almost 6 years ago
  • Updated over 5 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A gatling plugin for running load tests on Apache Dubbo(https://github.com/apache/incubator-dubbo) and other java ecosystem.

Gatling-Dubbo 2.0

【招聘】Java开发、测试开发等岗位,有意者请将简历投递至<canyuns【@】163.com>

Gatling的非官方Dubbo压测插件,基于Gatling 2.3.1,插件已在Dubbo 2.6.5上测试,但理论上所有Dubbo版本都适用,2.0插件采用普通API调用方式执行压测请求,如果你想使用泛化调用方式执行压测请求,请参考1.0插件,推荐使用2.0插件,即采用普通API调用方式,因为 dubbo 官方推荐生产上使用该方式,所以以同样的方式压测得到的结果,更具有参考意义,且2.0插件无需 dubbo 框架做任何改造。

区别于 Gatling-Dubbo 1.0 只支持 dubbo 压测,Gatling-Dubbo 2.0 不仅支持 dubbo 压测,还支持非 dubbo 的其他 java 调用压测,因为脚本中的 f 怎么写控制权在你手里,就像使用 Jmeter 压测 java 一样。

使用方法

打包Jar

按需修改配置:

  • 默认为4核8G内存机器配置了200线程池,与dubbo线程池一致,你也可以根据自己的机器配置使用API调整线程池大小,下述
  • 如果你使用其他Dubbo版本,请修改根目录下build.sbt中的libraryDependencies配置

如果你不需要修改配置,可以略过以下打包步骤,直接下载Jar包(该 Jar 包无应用依赖)

项目依赖sbt,请安装sbt 1.2.1,详见官方文档,执行

$ git clone https://github.com/youzan/gatling-dubbo.git
$ cd gatling-dubbo
$ sbt assembly

将上述jar包拷贝到/your-path-to/gatling-charts-highcharts-bundle-2.3.1/lib目录

$ 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

依赖

由于插件采用普通API调用方式执行压测请求,所以需要引入服务特定的 API 包,为了演示方便,这里直接将依赖写在了项目根目录下的 build.sbt 中:

name := "gatling-dubbo"

version := "1.0"

scalaVersion := "2.12.6"

libraryDependencies ++= Seq(
  "io.gatling" % "gatling-core" % "2.3.1" % "provided",
  "com.alibaba" % "dubbo" % "2.6.5",
  "com.youzan.xxx" % "xxx-api" % "1.xxx-RELEASE" exclude("ch.qos.logback", "logback-classic") //应用 API 包
)

assemblyOption in assembly := (assemblyOption in assembly).value.copy(includeScala = false)

创建Simulation和相应的json数据文件

参考gatling-dubbo/src/test/scala目录下的DubboTest.scala和data.json

DubboTest.scala具体说明请参考示例

check 说明
目前 check 支持两种,jsonPath 和 custom,如果 dubbo 返回值可以转化为 json(如 PlainResult、Map 等),则推荐使用 jsonPath 校验结果,如果 dubbo 返回值是 String 等类型,则推荐使用 custom 校验结果,即自定义校验逻辑,custom 的示例如下:

.check(custom((response: String) => {
              print(response)
              response == "expected response"
            }, "option error message"))

示例中展示的是单接口的例子,如果你想探测应用单机的真实水位,可以结合使用 gatling 的 randomSwitch 混合多接口且按生产环境真实的接口比例同时进行压测。

data.json

[
  {
    "kdtId": 160,
    "page": 1
  },
  {
    "kdtId": 160,
    "page": 2
  },
  {
    "kdtId": 160,
    "page": 3
  }
]

数据采用 json 数组保存,其中每一个 json 对象都是一次压测请求需要的完整参数,且为了方便通过 session 设置动态参数,数据结构采用一维结构,风格同 Jmeter。

执行Dubbo压测

$ bin/gatling.sh
GATLING_HOME is set to /your-path-to/gatling-charts-highcharts-bundle-2.3.1
Choose a simulation number:
     [0] dubbo.DubboTest
0
Select simulation id (default is 'dubbotest'). Accepted characters are a-z, A-Z, 0-9, - and _

Select run description (optional)

Simulation dubbo.DubboTest started...

================================================================================
2019-04-04 10:12:44                                           5s elapsed
---- Requests ------------------------------------------------------------------
> Global                                                   (OK=56     KO=0     )
> com.youzan.xxx.XxxService                                (OK=56     KO=0     )

---- scenario of xxx -----------------------------------------------------------
[--------------------------------------------------------------------------]  0%
          waiting: 0      / active: 10     / done:0
================================================================================

...

================================================================================
2019-04-04 10:13:11                                          31s elapsed
---- Requests ------------------------------------------------------------------
> Global                                                   (OK=320    KO=0     )
> com.youzan.xxx.XxxService                                (OK=320    KO=0     )

---- scenario of xxx -----------------------------------------------------------
[--------------------------------------------------------------------------]  0%
          waiting: 0      / active: 10     / done:0
================================================================================

Simulation dubbo.DubboTest completed in 31 seconds
Parsing log file(s)...
Parsing log file(s) done
Generating reports...

================================================================================
---- Global Information --------------------------------------------------------
> request count                                        320 (OK=320    KO=0     )
> min response time                                     44 (OK=44     KO=-     )
> max response time                                    343 (OK=343    KO=-     )
> mean response time                                    62 (OK=62     KO=-     )
> std deviation                                         42 (OK=42     KO=-     )
> response time 50th percentile                         49 (OK=49     KO=-     )
> response time 75th percentile                         53 (OK=53     KO=-     )
> response time 95th percentile                        160 (OK=160    KO=-     )
> response time 99th percentile                        275 (OK=275    KO=-     )
> mean requests/sec                                 10.323 (OK=10.323 KO=-     )
---- Response Time Distribution ------------------------------------------------
> t < 800 ms                                           320 (100%)
> 800 ms < t < 1200 ms                                   0 (  0%)
> t > 1200 ms                                            0 (  0%)
> failed                                                 0 (  0%)
================================================================================

Reports generated in 0s.
Please open the following file: /your-path-to/gatling-charts-highcharts-bundle-2.3.1/results/dubbotest-1554343959840/index.html

打开上述报告查看更多压测信息: Reports

gatling-dubbo 在有赞的应用示例

I 应用基线性能评估与容量规划: Reports

II 中心化限流效果验证: Reports

License

Apache License, Version 2.0

More Repositories

1

vant

A lightweight, customizable Vue UI library for mobile web apps.
TypeScript
23,055
star
2

vant-weapp

轻量、可靠的小程序 UI 组件库
JavaScript
17,673
star
3

zent

A collection of essential UI components written with React.
TypeScript
2,246
star
4

zan-proxy

An extensible proxy for PC/Mobile/APP developer
TypeScript
1,814
star
5

vant-demo

Collection of vant demos.
Vue
1,560
star
6

zanphp

PHP开发面向C10K+的高并发SOA服务 和RPC服务首选框架
PHP
1,437
star
7

nsq

A realtime distributed messaging platform (forked from https://github.com/nsqio/nsq)
Go
633
star
8

zanui-weapp

本仓库已不再维护,请移步 https://github.com/youzan/vant-weapp
JavaScript
535
star
9

bugCatcher

方便产品、开发、测试三方协同管理、测试、监控项目进度和质量,以持续交付。
Java
491
star
10

zan

高效稳定、安全易用、线上实时验证的全异步高性能网络库,通过PHP扩展方式使用。
C
459
star
11

php-co-koa

PHP异步编程: 手把手教你实现co与Koa
459
star
12

Bifrost

A delightful library for app business modular architecture.
Objective-C
398
star
13

YZSpamFilter

有赞垃圾内容过滤工具
Python
283
star
14

TitanRecyclerView

A handy RecyclerView can deal with all headers, footers, and loading shit.
Java
249
star
15

tiny-loader.js

A small loader that load CSS/JS in best way for page performance
JavaScript
204
star
16

raven-weapp

Sentry SDK for WeApp
JavaScript
159
star
17

show-me-the-code

TypeScript
151
star
18

felint

A smart way to eslint and stylelint for front end
JavaScript
127
star
19

weapp-plugin-demo

有赞微商城所有小程序插件的演示demo
JavaScript
113
star
20

YouzanMobileSDK-Android

有赞云AppSDK是为移动端应用打造的电商交易系统,通过一个SDK便可以在APP内集成有赞提供的整个交易服务。
Kotlin
113
star
21

SigmaTableViewModel

A simple view model for building organized and scalable TableViews.
Objective-C
106
star
22

httpfetch

对http请求进行封装的,通过对接口函数进行代理,实现优雅的http调用
Java
100
star
23

zanphp-doc

Zan PHP Framework doc
Python
99
star
24

zan_high_performance_mysql

mysql performance optimize book
98
star
25

beeyz

beeyz
Java
86
star
26

sprite-loader

A image sprite loader for webpack.
JavaScript
83
star
27

fast-uglifyjs-plugin

hight performance uglify plugin for webpack
JavaScript
71
star
28

systemtap-toolkit

YouZan systemtap toolkit to online analyze on production
Perl
69
star
29

ngx_http_ipip_module

nginx http module for ipip.net
C
65
star
30

YouzanMobileSDK-iOS

有赞云AppSDK是为移动端应用打造的电商交易系统,通过一个SDK便可以在APP内集成有赞提供的整个交易服务。
Objective-C
62
star
31

zanhttpdemo

HTTP demo for Zan PHP Framework
PHP
57
star
32

go-nsq

Go
56
star
33

open-sdk-php

有赞云网关 SDK for PHP
PHP
54
star
34

php-nsq-client

php nsq client
PHP
38
star
35

nsqJavaSDK

nsq client for java
Java
37
star
36

vue-cli-template-vant

注意:本仓库适用于 vue-cli 2.0, vue-cli 3.0 请参考:https://youzan.github.io/vant/#/zh-CN/quickstart
JavaScript
35
star
37

youzan-sdk

Yet Another Node.js SDK for http://open.youzan.com
JavaScript
33
star
38

zent-kit

[DEPRACATED] React 组件库开发脚手架
JavaScript
28
star
39

vant-doc

本仓库已废弃,请使用 https://github.com/youzan/vant/tree/dev/packages/vant-cli
Vue
27
star
40

zan-installer

Youzan Zan Php Installer
PHP
26
star
41

zan-tool

Zan Node Web 框架配套开发工具
JavaScript
23
star
42

yz-cloud-boot

有赞云有容器应用PHP框架
PHP
21
star
43

open-sdk-node

有赞云网关 SDK for Node
JavaScript
20
star
44

vant-icons

本仓库已迁移至 https://github.com/youzan/vant/tree/dev/packages/vant-icons
CSS
18
star
45

zan-thrift

zan thrift代码生成工具
C++
17
star
46

create-utils

Build your own js library by running one command
JavaScript
15
star
47

ngx_http_html_sanitize_module

It's a nginx http module to sanitize HTML5 with whitelisted elements, whitelisted attributes and whitelisted CSS property
HTML
15
star
48

zanphp.io-server

Proudly build with Zan PHP Framework
CSS
13
star
49

open-sdk-Csharp

有赞云网关Api调用C# SDK
C#
12
star
50

spark-nsq-consumer

spark-nsq-consumer
Scala
10
star
51

zent-seed

[DEPRECATED] React 组件库项目模版,请配合 https://github.com/youzan/zent-kit 使用
JavaScript
8
star
52

felint-config

Shell
6
star
53

yz_aerospike

youzan aerospike client branch
C
6
star
54

zan-doc

PHP
5
star
55

zanphp.io

Zan PHP Framework official site
CSS
5
star
56

zan-utils

TypeScript
4
star
57

zantcpdemo

PHP
4
star
58

zanwebsocketdemo

PHP
4
star
59

extension-point-api

有赞云扩展点PHP桩代码
PHP
4
star
60

zanhttp-boilerplate

Youzan ZanPhp HTTP project Boilerplate
PHP
4
star
61

zent-beta

Zent beta 版文档网站
HTML
3
star
62

YouzanHarmonySDK

Batchfile
2
star
63

cloud-connector-doc

云连接器文档
Shell
2
star
64

eslint-plugin-youzan

Eslint plugin for youzan
JavaScript
2
star
65

yz-cloud-boot-demo-app

有赞云有容器App定制PHP测试Demo工程
JavaScript
2
star
66

youzan.github.io

HTML
1
star
67

vue-cli-template-yzae

A vue-cli template for youzan app-engine developer, forked from vue-cli-template-vant.
JavaScript
1
star
68

zantcp-boilerplate

Youzan ZanPHP TCP project Boilerplate
PHP
1
star
69

zan-snippets

Code snippets for various editors at Youzan
Shell
1
star
70

zan-user-guide

Python
1
star
71

zanwebsocket-boilerplate

PHP
1
star