官网地址:https://gatling.io/
Gatling专为进行连续负载测试而设计,并与您的开发管道集成在一起。加特林(Gatling)包括网络记录仪和彩色报告。号称最佳测试Web应用程序的开发人员工具。
Gatling FrontLine是Gatling的管理界面,其中包括用于集成和自动化的高级指标和高级功能。
使用
首先,到官网下载最新版的gatling:
https://repo1.maven.org/maven2/io/gatling/highcharts/gatling-charts-highcharts-bundle/2.3.1/gatling-charts-highcharts-bundle-2.3.1-bundle.zip
然后解压缩到本地路径:
unzip gatling-charts-highcharts-bundle-2.3.1.zip
mv gatling-charts-highcharts-bundle-2.3.1 gatling
然后看一下打压脚本:
import io.gatling.core.Predef._
import io.gatling.http.Predef._
import scala.concurrent.duration._
class HelloSimulation extends Simulation {
val httpConf = http
.baseURL("http://192.168.99.100:30888")
val scn = scenario("HelloSimulation").during(30) {
exec(http("hello_1")
.get("/lmsia-abc/api/"))
}
setUp(
scn.inject(atOnceUsers(2000))
).protocols(httpConf)
}
如上,Gating的打压脚本稍微复杂一些:
- 服务根地址192.168.99.100:30888
- 访问的get请求"/lmsia-abc/api/"
- 并发2000个用户
执行一下打压:
gatling.sh -sf . -s HelloSimulation
结果中可以直接看到各项统计结果:
---- Global Information --------------------------------------------------------
> request count 353505 (OK=353505 KO=0 )
> min response time 0 (OK=0 KO=- )
> max response time 1644 (OK=1644 KO=- )
> mean response time 170 (OK=170 KO=- )
> std deviation 122 (OK=122 KO=- )
> response time 50th percentile 143 (OK=143 KO=- )
> response time 75th percentile 219 (OK=219 KO=- )
> response time 95th percentile 408 (OK=408 KO=- )
> response time 99th percentile 606 (OK=606 KO=- )
> mean requests/sec 11047.031 (OK=11047.031 KO=- )
---- Response Time Distribution ------------------------------------------------
> t < 800 ms 353348 (100%)
> 800 ms < t < 1200 ms 148 ( 0%)
> t > 1200 ms 9 ( 0%)
> failed 0 ( 0%)
================================================================================
Reports generated in 2s.