Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
はじめての Gatling
Search
n0ts
August 19, 2016
Technology
68
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
はじめての Gatling
n0ts
August 19, 2016
More Decks by n0ts
See All by n0ts
MySQL Casual Talks Vol.3 〜カジュアルだよこわくないよ〜
n0ts
2
100
Other Decks in Technology
See All in Technology
[JAWS-UG彩の国埼玉#12]そろそろ準備する?re:Invent2026をやさしく解説 / reinvent2026-sainokuni
sh_fk2
1
340
宣言型部分更新は何を解決しどこへ向かうのか
shuta13
1
460
分析の民主化を支えるメタデータ整備の実践
kakehashi
PRO
4
1.4k
夫婦で子育てするための育児標準化
codmoninc
PRO
0
340
Active Record Connection Adaptersにおける長年の課題に再び取り組む
yahonda
0
150
JAWS-UGグッズ職人仕事の流儀
kentapapa
0
100
LambdaWebFunctionsを試してみた / exploring-lambda-web-functions
koukihosaka
1
340
PHPカンファレンス関西の招待状 / Invitation to PHP Conference Kansai
ykanoh
0
110
JAWSUG TOHOKU 青森支部 「LoGoチャット」のAWS移行で 乗り越えたこと
taketakekaho
0
330
脆弱性診断って、何をしているの? 〜弱点を見つけて、会社の改善につなげるまで〜
keeg
0
920
TinyGoでオブザーバビリティ?OpenTelemetryはTinyGoで使えるのか / Is OpenTelemetry available in TinyGo environment?
ymotongpoo
2
140
Local CI × GitHub Actions
gogutan
2
190
Featured
See All Featured
How to Build an AI Search Optimization Roadmap - Criteria and Steps to Take #SEOIRL
aleyda
1
2.2k
A designer walks into a library…
pauljervisheath
211
25k
Avoiding the “Bad Training, Faster” Trap in the Age of AI
tmiket
0
270
Intergalactic Javascript Robots from Outer Space
tanoku
273
28k
Designing for Timeless Needs
cassininazir
1
530
A better future with KSS
kneath
240
18k
Fashionably flexible responsive web design (full day workshop)
malarkey
409
67k
Introduction to Domain-Driven Design and Collaborative software design
baasie
1
1k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
12
1.9k
Exploring the relationship between traditional SERPs and Gen AI search
raygrieselhuber
PRO
4
4.4k
GraphQLの誤解/rethinking-graphql
sonatard
75
12k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
508
140k
Transcript
͡Ίͯͷ Gatling Naoya Nakazawa @n0ts 2016/08/19
࣍ • Gatling ͱ • Gatling ͷΠϯετʔϧํ๏ • Gatling Ϩίʔμʔ
• Gatling ͷ͍ํ • Gatling ͷϨϙʔτ • Gatling ͷ࣮ྫ Tips
Gatling ͱ • http://gatling.io • Scala ϕʔεͷߴෛՙςετϑϨʔϜϫʔΫ • ab
wrk ͷΑ͏ͳϕϯνϚʔΫʹ͍͕ۙɺScala Ͱϩ δοΫΛهड़͢Δ͜ͱ͕Ͱ͖Δ • ab (Apache Bench): • https://httpd.apache.org/docs/2.4/programs/ ab.html • wrk: • https://github.com/wg/wrk
ಛ • HTML ϨϙʔτͰग़ྗ͢Δ͜ͱ͕Ͱ͖Δ • HTTP GET Ҏ֎ʹ POST ʹରԠ͍ͯ͠Δ
• ϦϑΝϥʔɺΫοΩʔͷ༩σϑΥϧτͰରԠ͍ͯ͠ Δʂ • Scala ྗ͕ͯ͘Ҏ֎ͱ؆୯ʹઃఆΛॻ͘͜ͱ͕ग़དྷ Δʢࣗݧʂʣ
Πϯετʔϧ 1. JDK8 Ҏ͕߱ඞཁͳͷͰɺΠϯετʔϧ 2. ެࣜϗʔϜϖʔδ͔Β zip ϑΝΠϧΛμϯϩʔυ http://gatling.io/#/download 3.
Linux / OS X ͳΒ bin/gatling.sh ͋Δ͍ɺWindows ͳΒ bin/gatling.bat Ͱ࣮ߦ͢Δ͚ͩ
Ϩίʔμʔ • Gatling ͷςετγφϦΦΛࣗಈతʹੜ͢Δπʔϧ • bin/recorder.sh Ͱ࣮ߦ͢Δ • ϨίʔμʔͰ։࢝͢ΔͱɺϓϩΩγܦ༝ͷϦΫΤετ ͕ࣗಈతʹ
Gatling ͷγϛϡϨʔγϣϯϑΝΠϧͱ͠ ͯอଘ͞ΕΔ
Ϩίʔμʔը໘
ϨίʔμʔͰੜ͞ΕΔγφϦΦͷྫ package computerdatabase // ύοέʔδ໊ import io.gatling.core.Predef._ // ඞཁͳΠϯϙʔτͨͪ import
io.gatling.http.Predef._ import scala.concurrent.duration._ class BasicSimulation extends Simulation { // ΫϥεఆٛɺSimulation Λܟশ͠ͳ͍ͱ͍͚ͳ͍ val httpConf = http // HTTP ϦΫΤετͷڞ௨ઃఆ .baseURL("http://computer-database.gatling.io") // ϦΫΤετରͷ URL .acceptHeader("text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8") // ڞ௨ͷ HTTP ϔομʔ .doNotTrackHeader("1") // DNT ϔομʔͷૹ৴ .acceptLanguageHeader("en-US,en;q=0.5") // ड͚ೖΕΔݴޠϔομʔͷૹ৴ .acceptEncodingHeader("gzip, deflate") // ΤϯίʔσΟϯάϔομʔͷૹ৴ .userAgentHeader("Mozilla/5.0 (Windows NT 5.1; rv:31.0) Gecko/20100101 Firefox/31.0") // ϢʔβΤʔδΣϯτͷૹ৴ val scn = scenario("BasicSimulation") // ςετγφϦΦͷఆٛ .exec(http("request_1") // HTTP ϦΫΤετ໊ɺ"request_1" ࠷ऴϨϙʔτʹදࣔ͞ΕΔ .get("/")) // URI / GET ϦΫΤετ͢Δ .pause(5) // Ұ࣌εϦʔϓλΠϜ setUp( // ͜ͷγϛϡϨʔγϣϯͰ࣮ߦ͢ΔγφϦΦͷηοτΞοϓ scn.inject(atOnceUsers(1)) // scn ͱ͍͏໊લͰ 1 γϯάϧϢʔβͰϦΫΤετ͢Δ ).protocols(httpConf) // ࠷ॳͷ HTTP ϦΫΤετͷڞ௨ઃఆΛ༩͢Δ }
࣮ߦྫ $ bin/gatling.sh GATLING_HOME is set to $GATLING_ROOT Choose a
simulation number: [0] test.BasicSimulation [1] test.FooSimulation ※番号を入力 1 ... ---- Global Information -------------------------------------------------------- > request count 10 (OK=10 KO=0 ) > min response time 5 (OK=5 KO=- ) > max response time 58 (OK=58 KO=- ) > mean response time 16 (OK=16 KO=- ) > std deviation 14 (OK=14 KO=- ) > response time 50th percentile 12 (OK=12 KO=- ) > response time 75th percentile 17 (OK=17 KO=- ) > mean requests/sec 5.141 (OK=5.141 KO=- ) *1 ---- Response Time Distribution ------------------------------------------------ > t < 800 ms 10 (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/scenariosimulation-xxx/index.html *1: ඵؒ͋ͨΓͷॲཧͨ͠ΓΫΤετɺKO NG ͱ͍͏ҙຯ
࣮ߦ݁Ռ • ͋Θͤͯ results ҎԼʹ HTML ϑΝΠϧͱͯ͠ग़ྗ͞Ε Δ http://gatling.io/docs/2.2.2/general/reports.html
Gatling ͷ࣮ྫ
ಉ͡ϦΫΤετΛ܁Γฦ͢ • 5 ճ࿈ଓͰ܁Γฦ͢ val scn = scenario("RepeatBenchmark") .repeat(5, "n")
{ exec(http("top").get("/")) }
͋Δ݅ͷͱ͖ͷΈϦΫΤετΛ͢Δ • scenarioProperty ͕ pv ͷͱ͖ϦΫΤετΛ͢Δ val scenarioProperty = System.getProperty("scenario",
"").toString val scn = scenario("DoIfBenchmark") .doIf(scenarioProperty, "pv") { exec(http("pv").get("/pv")) }
͋Δׂ߹͝ͱʹϦΫΤετΛ͢Δ • / Λ 50%ɺ/foo Λ 20%ɺ/bar Λ 30% ͣͭϦΫΤετ
͢Δ val scn = scenario("RandomBenchmark") .randomSwitch( 50.0 -> exec(http("top").get("/")), 20.0 -> exec(http("foo").get("/foo")), 30.0 -> exec(http("bar").get("/bar")) )
ϦΫΤετʹಈతʹΫοΩʔΛ༩͢Δ • / ͷΫοΩʔ uid Λ /cookie ༩͢Δ val scn
= scenario("CookieBenchmark") .exec(http("top") .get("/") .check(headerRegex("Set-Cookie", "uid=(.*); Expires=.*; Domain=.*; Path=.*").saveAs("uid"))) .exec(addCookie(Cookie("uid", "${uid}"))) .exec(http("cookie").get("/"))
ϦΫΤετʹಈతʹ UA Λมߋ͢Δ • /baz ͷϦΫΤετ "bar UA" ʹ͢Δ val
userAgent = Map("User-Agent" -> "bar UA") val scn = scenario("UABenchmark") .exec(http("baz") .get("/baz") .headers(userAgent) )
εςʔλείʔυ 303 εςʔλε OK ͱ͢Δ • /redirect 303 Λฦͯ͠ɺϦμΠϨΫτ͠ͳ͍
val scn = scenario("RedirectBenchmark") .exec(http("top") .get("/redirect") .disableFollowRedirect .check(status.is(303)) )
2.2 Ͱͷมߋ - JDK & Core • JDK8 ͕ඞਢʹͳΓ·ͨ͠ʢσϑΥϧτ G1
GCʣ • FeederʢIterator[Map[String, T]] ͷΤΠϦΞεʣίϯςϯπʹ ରͯ͠ shuffle Ͱ͖ΔΑ͏ʹͳΓ·ͨ͠ http://gatling.io/docs/ 2.2.2/session/feeder.html#feeder • AsssertionʢϨεϙϯελΠϜࣦഊͨ͠ϦΫΤετʹରͯ͠Ͳ ͷ͘Β͍ڐ༰͢Δ͔ઃఆ͢Δͷʣʹ per-million ͕αϙʔτ͞ Εͨ • 2.2.1 ͔Βɺ͋Δ݅Λຬ͍ͨͯ͠Δͱ͖࣮ߦ͢Δػߏ Conditional Checking ͕αϙʔτ͞Εͨ
2.2 Ͱͷมߋ - HTTP • Netty 4 ϕʔεͰ࠶࣮͞Εͨʢͨͩ͠ Linux ্ͰͷΈར༻Մೳʣ
• OpenSSL ͱ BoringSSL(Google's fork) ͕αϙʔτ͞Εͨ • HTML ϑΥʔϜͰೖྗΛΩϟϓνϟʔͯ͠ɺͦͷ݁ՌΛ֬ೝͰ͖ ΔΑ͏ʹͳͬͨ • form("cssSelector").saveAs("myForm") • HTTP ϙʔϦϯά͕αϙʔτ͞Εͨ • exec(polling.every(10 seconds).exec(http("name").get("url"))) • exec(polling.stop) • ϗετ໊ͷΤΠϦΞε͕Մೳʹͳͬͨ • ෳͷϩʔΧϧΞυϨεʹରͯ͠ϦΫΤετͰ͖ΔΑ͏ʹͳͬͨ
2.2 Ͱͷมߋ - Reports • JUnit ͷϑΥʔϚοτϨϙʔτ͕αϙʔτ͞Εͨ • ࣄલʹઃఆͨ͠άϧʔϓ͝ͱʹϨϙʔτΛੜͰ͖ΔΑ ͏ʹͳͬͨ
• Maven ϓϥάΠϯ͕ test ͱ integration-test ͕αϙʔ τ͞Εͨ
͜ͷଞެࣜυΩϡϝϯτΛͲ͏ͧ http://gatling.io/docs/2.2.2/general/ index.html
Enjoy!!!