前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Gatling性能测试(一)

Gatling性能测试(一)

作者头像
无涯WuYa
发布2021-11-05 09:35:54
8590
发布2021-11-05 09:35:54
举报

初识Gatling

Gatling是一款基于Scala 开发的高性能服务器性能测试工具,同时也是一款功能强大的负载测试工具,它为易于使用,高可维护性和高性能而设计。开箱即用,Gatling由于对HTTP协议的出色支持,使其成为负载测试任何HTTP服务器的首选工具。官方地址:https://gatling.io/get-started/。

使用Gatling前首先需要搭建Java的环境,保障已经搭建了Java的环境。下载地址为:https://gatling.io/open-source/,下载成功后,进行解压,目录信息为:

下来进行配置环境,配置后的信息具体为:

代码语言:javascript
复制
#Gatling
export GATLING_HOME=/Applications/devOps/tools/gatling
export PATH=$PATH:$GATLING_HOME/bin

配置环境变量成功后,在控制台输入:

代码语言:javascript
复制
recorder.sh

按下回车键,就会显示Gatling的GUI的界面,具体如下:

Gatling实战

下面就以官方的案例来演示下Gatling的基本使用,在控制台执行输入如下命令:

代码语言:javascript
复制
gatling.sh
#输入如上的命令后,显示如下的信息
GATLING_HOME is set to /Applications/devOps/tools/gatling
Choose a simulation number:
[0] computerdatabase.BasicSimulation
[1] computerdatabase.advanced.AdvancedSimulationStep01
[2] computerdatabase.advanced.AdvancedSimulationStep02
[3] computerdatabase.advanced.AdvancedSimulationStep03
[4] computerdatabase.advanced.AdvancedSimulationStep04
[5] computerdatabase.advanced.AdvancedSimulationStep05
#在控制台输入0,就会显示输入的信息,以及最后显示测试报告的结果信息,具体详细过程如下
0
Select run description (optional)

Simulation computerdatabase.BasicSimulation started...

Generating reports...

================================================================================
---- Global Information --------------------------------------------------------
> request count                                         13 (OK=13     KO=0     )
> min response time                                    241 (OK=241    KO=-     )
> max response time                                   1478 (OK=1478   KO=-     )
> mean response time                                   458 (OK=458    KO=-     )
> std deviation                                        339 (OK=339    KO=-     )
> response time 50th percentile                        301 (OK=301    KO=-     )
> response time 75th percentile                        527 (OK=527    KO=-     )
> response time 95th percentile                       1100 (OK=1100   KO=-     )
> response time 99th percentile                       1402 (OK=1402   KO=-     )
> mean requests/sec                                  0.448 (OK=0.448  KO=-     )
---- Response Time Distribution ------------------------------------------------
> t < 800 ms                                            11 ( 85%)
> 800 ms < t < 1200 ms                                   1 (  8%)
> t > 1200 ms                                            1 (  8%)
> failed                                                 0 (  0%)
================================================================================

Reports generated in 0s.
Please open the following file: /Applications/devOps/tools/gatling/results/basicsimulation-20211101134633997/index.html

打开最后的HT ML的测试报告,会显示详细的性能测试结果数据和对应的指标数据,具体如下所示:

下面来测试登录服务的性能,需要编写具体的测试脚本,具体为:在gatling/user-files/simulations/computerdatabase目录下,编写案例代码,具体代码是使用Scala语言进行编写的,源码如下:

编写代码成功后,再次执行gatling.sh,显示如下:

选择1,开始执行,如下是执行的结果信息,具体结果如下:

结合如上的案例,可以看到Gatling测试工具对服务端的负载很高,比较适合在在微服务的架构下验证服务的队列机制和高并发下服务的响应机制以及承载能力。感谢您的阅读,后续会持续介绍该工具对服务端的案例应用。

本文参与 腾讯云自媒体分享计划,分享自微信公众号。
原始发表:2021-11-01,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 Python自动化测试 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档