絶品ゆどうふのタレ

ふと気づいたことを綴るだけのメモ

負荷テストツールGatlingを触ってみた


Gatling

Quickstart

GUIMac

Gatling


Java/Scala

JMater




HTML

developer




3JMater(XML)


Gatling simulation scripts are written in Scala, but don’t panic!




Install


JavaGalingGatlingunzip
% brew cask install java
% wget https://repo1.maven.org/maven2/io/gatling/highcharts/gatling-charts-highcharts-bundle/2.1.6/gatling-charts-highcharts-bundle-2.1.6-bundle.zip
% unzip gatling-charts-highcharts-bundle-2.1.6-bundle.zip





 http://computer-database.herokuapp.com/ 


PCCGM

Play framework

 https://github.com/playframework/playframework/tree/2.2.x/samples/scala/computer-database






(一) 

(二) mackbook

(三) 

(四) home

(五) 

(六) 



Gatling Recorder


Gatling Recorder使

Gatling RecorderproxyScala

Scalaproxy


Gatling Recorder
% cd gatling-charts-highcharts-bundle-2.1.6
% bin/recorder.sh



f:id:Yudoufu:20150613170429p:plain
WebGatling Recorder

f:id:Yudoufu:20150613170522p:plain


Start proxy

Tipspluginsecret window Gatling RecorderTAG




RecorderSearch

http://computer-database.herokuapp.com/ 

mackbook 

Macbook Pro

Browse

http://computer-database.herokuapp.com/ 

Next



Edit

http://computer-database.herokuapp.com/ 

Add new computer

()


f:id:Yudoufu:20150613170548p:plain
Stop & Saveuser-files/simulations/computerdatabase/BasicSimulation.scala


package computerdatabase

import scala.concurrent.duration._

import io.gatling.core.Predef._
import io.gatling.http.Predef._
import io.gatling.jdbc.Predef._

class BasicSimulation extends Simulation {

    val httpProtocol = http
        .baseURL("http://computer-database.herokuapp.com")
        .inferHtmlResources(BlackList(""".*\.css""", """.*\.js""", """.*\.ico"""), WhiteList())
        .acceptHeader("text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8")
        .acceptEncodingHeader("gzip, deflate, sdch")
        .acceptLanguageHeader("ja,en-US;q=0.8,en;q=0.6")
        .userAgentHeader("Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.39 Safari/537.36")



    val uri1 = "http://computer-database.herokuapp.com"

    val scn = scenario("BasicSimulation")
        // Search
        .exec(http("request_0")
            .get("/"))
        .pause(5)
        .exec(http("request_1")
            .get("/computers?f=macbook"))
        .pause(2)
        .exec(http("request_2")
            .get("/computers/6"))
        .pause(10)
        // Browse
        .exec(http("request_3")
            .get("/"))
        .pause(2)
        .exec(http("request_4")
            .get("/computers?p=1")
            .resources(http("request_5")
            .get(uri1 + "/computers?p=2"),
            http("request_6")
            .get(uri1 + "/computers?p=3")))
        .pause(2)
        .exec(http("request_7")
            .get("/computers/72"))
        .pause(1)
        .exec(http("request_8")
            .get("/"))
        .pause(1)
        .exec(http("request_9")
            .get("/computers?p=1")
            .resources(http("request_10")
            .get(uri1 + "/computers?p=2")))
        .pause(3)
        .exec(http("request_11")
            .get("/computers/70"))
        .pause(10)
        // Edit
        .exec(http("request_12")
            .get("/"))
        .pause(1)
        .exec(http("request_13")
            .get("/computers/new"))

    setUp(scn.inject(atOnceUsers(1))).protocols(httpProtocol)
}



Gatling
% bin/gatling.sh

(0) BasicSimulation

Enter
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
Select simulation id (default is 'basicsimulation'). Accepted characters are a-z, A-Z, 0-9, - and _

Select run description (optional)

Simulation computerdatabase.BasicSimulation started...


================================================================================
---- Global Information --------------------------------------------------------
> request count                                         18 (OK=18     KO=0     )
> min response time                                    191 (OK=191    KO=-     )
> max response time                                    414 (OK=414    KO=-     )
> mean response time                                   217 (OK=217    KO=-     )
> std deviation                                         64 (OK=64     KO=-     )
> response time 50th percentile                        195 (OK=195    KO=-     )
> response time 75th percentile                        197 (OK=197    KO=-     )
> mean requests/sec                                  0.441 (OK=0.441  KO=-     )
---- Response Time Distribution ------------------------------------------------
> t < 800 ms                                            18 (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: results/basicsimulation-1434181826508/index.html


results/basicsimulation-1434181826508/index.html
% open results/basicsimulation-1434181826508/index.html

f:id:Yudoufu:20150613170606p:plain
rps

f:id:Yudoufu:20150613170622p:plain
f:id:Yudoufu:20150613170634p:plain
f:id:Yudoufu:20150613170721p:plain
使