Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
load-test-with-gatling
Search
Hirokazu Maruta
February 06, 2019
Technology
0
250
load-test-with-gatling
負荷試験を実施したのでその何ようについて社外発表で登壇しました。
How to Run a load test with gatling.
Hirokazu Maruta
February 06, 2019
Tweet
Share
More Decks by Hirokazu Maruta
See All by Hirokazu Maruta
encryption
mochisuna
0
94
わかった気になるチューリングマシン
mochisuna
0
38
Elementary algorithm
mochisuna
0
17
ssh-dynamic-forward
mochisuna
0
46
ServerlessFramework-Trello
mochisuna
0
26
TechBash Slack Reaction Award
mochisuna
0
43
techbash-clasp
mochisuna
0
54
vuejs-night-publish
mochisuna
0
840
surprise-lt-for-intern-vol-2
mochisuna
0
49
Other Decks in Technology
See All in Technology
Flutterによる 効率的なAndroid・iOS・Webアプリケーション開発の事例
recruitengineers
PRO
0
190
RAMP2024
takeyukitamura
1
120
【Startup CTO of the Year 2024 / Audience Award】アセンド取締役CTO 丹羽健
niwatakeru
0
2.2k
Making your applications cross-environment - OSCG 2024 NA
salaboy
0
220
Is Go A Good Language to Build Compilers?
kennethanceyer
0
110
OpenLLMetry-Hands-On 生成AIアプリを観測してみよう!OpenLLMetryハンズオン編
tkhresk
0
100
Why App Signing Matters for Your Android Apps - Android Bangkok Conference 2024
akexorcist
0
140
組織成長を加速させるオンボーディングの取り組み
sudoakiy
3
360
あなたの知らない Function.prototype.toString() の世界
mizdra
PRO
4
2.5k
オープンソースAIとは何か? --「オープンソースAIの定義 v1.0」詳細解説
shujisado
13
1.6k
クラウドインフラ構築における.NETとその他IaCの比較
ymd65536
1
110
SRE×AIOpsを始めよう!GuardDutyによるお手軽脅威検出
amixedcolor
1
270
Featured
See All Featured
The Illustrated Children's Guide to Kubernetes
chrisshort
48
48k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
44
2.2k
4 Signs Your Business is Dying
shpigford
180
21k
Build The Right Thing And Hit Your Dates
maggiecrowley
33
2.4k
Fontdeck: Realign not Redesign
paulrobertlloyd
82
5.2k
Six Lessons from altMBA
skipperchong
27
3.5k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
6
450
Become a Pro
speakerdeck
PRO
25
5k
Designing the Hi-DPI Web
ddemaree
280
34k
10 Git Anti Patterns You Should be Aware of
lemiorhan
655
59k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
28
9.1k
GitHub's CSS Performance
jonrohan
1030
460k
Transcript
ԶͷΨτϦϯά͕ՐΛͥ͘ʂ giftee SaaS div. Engineer ·ΔͨͻΖ͔ͣ ʢެ։൛ʣ
ڈͷ12݄ͷ
େΩϟϯϖʔϯ͕͋Γ·ͨ͠ ެ։༻ࢿྉͳͷͰ ৄࡉΛফ͍ͯ͠·͢
Ͱɻ
Α͋͘Δ
ࠓͷγεςϜͬͯɺ େنҊ݅ ͑ΒΕΔΜ͚ͩͬʁ
ʮΑͬ͠Όෛՙςετͨ͠Ζʂʯ ኯ(ʈ)(ʈ)
ԶͷΨτϦϯά͕ՐΛͥ͘ʂ giftee SaaS div. Engineer ·ΔͨͻΖ͔ͣ ʢެ։൛ʣ
ࣗݾհ • ؙాʢ·ΔͨͻΖ͔ͣʣ • Twitter: @mochi_suna • giftee.co SaaSνʔϜΤϯδχΞ •
झຯɿϐΞϊɺϘυήɺΞΠίϯ࡞ʢΧούʣ • ۙگɿ4݄ʹ݁ࠗࣜΛ߇͑ͯ·͢
͓ࣄʹ͍ͭͯ͏গ͠ ٠͕ਅ໘ʹॻ͍ͯͨͷͰ۷ΓԼ͛·͢ɾɾɾ • ֎෦ൢചը໘ͷCMS • νέοτൃ݊APIͷ࡞ • νέοτ݊໘ͷ࡞
Agenda • What is "Gatling" • Why Gatling • How
to use Gatling • Tips • Report
ɾɾɾͱ͍͏͜ͱͰ
ࠓճऔΓѻ͏ͷ
None
※ͷͩͱ͜Ε͕ਅͬઌʹࢥ͍͖ͭ·͢ ໊લ͔Βੌͦ͏ ɺອըͷ ѱಙਓ͕υϠإͰ ΨτϦϯάߏ͑Δ͕࢟ ͜͜ʹೖ͍ͬͯ·ͨ͠
What is "Gatling" • "Load and Performance testing framework" •
"Open-source, based on Scala” • JMeterʹର͢Δ͙Β͍༗໊ • Scalaྗͳׂͯ͘ͱॻ͚Δ • ϨϙʔτػೳͳͲཉ͍͠ػೳ͕ॆ࣮
ʑ໊͍͠લͩ͠ྑͦ͞͏ શྗͰஶ࡞ݖʹ՞ചΔελΠϧ ͕ ΨτϦϯάͷ αΠϘʔάೣ Վ͍ͳ͕Β ΨτϦϯάΛͿͬ์͢ ঁͷࢠ ͕ ΨτϦϯάͷ
ΨϯμϜ ΠϯΫͰԚ͠߹͏ ήʔϜͷΩϟϥ ৭ʑೖͬͯ·ͨ͠ ΨτϦϯάߏ͑ͨ ѱಙқͷ υϠإ
ͳͥGatlingΛ͏ʁ
ଟ༷ͳෛՙࢼݧπʔϧ • ੈͷதʹෛՙࢼݧπʔϧͬͯࢁ΄Ͳ͋Δ͚Ͳ…
༻్ʹ߹ΘͤͯબΜͩΒྑ͍ ࠓճͷ߹ • flood.io (※)Ͱςετ݁ՌΛڞ༗͍ͨ͠ • ͱʹ͔͘ظ͕ؒ͘ૣ͘࡞Γ͔ͨͬͨ • γʔέϯεςετ͍͢͠ Λຬͨ͢ͷͰ͋ΕԿͰΑ͔ͬͨ
flood.io ΫϥυϕʔεͷϩʔυςεταʔϏε • ෛՙࢼݧͷͨΊʹࣗલͰαʔόʔཱͯΔͷ͠ΜͲ͍ • ϩʔΧϧͩͱࢼݧ༰ˍ݁Ռͱ͍͏ܗͰڞ༗͠ʹ͍͘ ͜͏͍ͬͨΛΑ͠ͳʹͯ͘͠ΕΔ
flood.io͕αϙʔτ
ݸਓతͳͰ ʮJMeterͰҎલςετͨ͜͠ͱ͋ΔΑʯ ʮ͓ɺΒ͍·͢Ͷʯ ʮͲΕͲΕʯ
ݸਓతͳͰ ʮJMeterͰҎલςετͨ͜͠ͱ͋ΔΑʯ ʮ͓ɺΒ͍·͢Ͷʯ ʮͲΕͲΕʯ
ݸਓతͳͰ ʮJMeterͰҎલςετͨ͜͠ͱ͋ΔΑʯ ʮ͓ɺΒ͍·͢Ͷʯ ʮͲΕͲΕʯ
͋ͬɺ͜ΓΌແཧͩ ʹ͠Α͏ɻ
ͪͳΈʹ ࠓճૉૣ͍ରԠ͕Ͱ͖ͳ͍ͱஅ͕ͨ͠… • https://github.com/flood-io/ruby-jmeter
ͪͳΈʹ ࠓճૉૣ͍ରԠ͕Ͱ͖ͳ͍ͱஅ͕ͨ͠… • https://github.com/flood-io/ruby-jmeter • JMeterͷςετγφϦΦΛRubyͰॻ͚Δ • flood.io͕࡞͍ͬͯΔ ͜Μͳͷ͋Δʢશ෦ऴΘ͔ͬͯΒͬͨʣ
ଟ༷ͳෛՙࢼݧπʔϧʢ࠶ܝʣ • ੈͷதʹෛՙࢼݧπʔϧͬͯࢁ΄Ͳ͋Δ͚Ͳ…
ଟ༷ͳෛՙࢼݧπʔϧʢ࠶ܝʣ • ੈͷதʹෛՙࢼݧπʔϧͬͯࢁ΄Ͳ͋Δ͚Ͳ… ༻్ʹ߹Θ͖ͤͯͳͷ͓͏
ɹɹ ্࠷ڧͷੜ͕ڝ͏ͳͱ་͢γʔϯ ɹɹ͕ೖ͍ͬͯ·ͨ͠
ຊɿGatlingΛ͏
Πϯετʔϧ 1.JDK8ͷΠϯετʔϧ 2.ຊՈαΠτ͔ΒzipΛDL 3.zipΛల։ Ҏ্
ϓϩδΣΫτͷத • ల։ͨ͠ϓϩδΣΫτͷσΟϨΫτϦߏ
ϓϩδΣΫτͷத • ओʹ͜ͷล͕͏ͱ͜Ζ ɿgatlingͷ࣮ߦϑΝΠϧͳͲʢbin/gatling.shʣ ɿ࣮ߦ݁ՌͷϨϙʔτ ɿ࣮ߦ͍ͨ͠εΫϦϓτΛஔ͘ͱ͜Ζ
user-filesʹϑΝΠϧΛՃ • user-files/…/advancedԼ • σϑΥϧτͰαϯϓϧ͕͋Δ • ׂͱࢀߟʹͳΔ
͜͜ʹεΫϦϓτΛՃ ؆୯ͳྫ 1. ੩తϖʔδʹΞΫηε 2. 200OKΛ֬ೝ 3. ࠷ॳʹ10userΛੜ
ࡉ͔͘ݟ͍ͯ͘ http.baseURL • ςετରͷURLΛࢦఆ • γφϦΦ͜͜Ͱࢦ ఆͨ͠URLʹର࣮͠ߦ • setUp(*).protocols
ࡉ͔͘ݟ͍ͯ͘ scenario • ॲཧ͍ͨ͠γφϦΦ • ग़ྗ໊ΛࢦఆͰ͖Δ • γφϦΦಉ࢜Λ࿈ଓͰܨ͛Δ ͜ͱͰ͖Δ •
inject͢Δ͜ͱͰϢʔβʔͷ ಈ͖Λ੍ޚͰ͖Δ
ࡉ͔͘ݟ͍ͯ͘ setUp • ϢʔβʔΛ੍ޚ • ʮԿਓͷϢʔβʔ͕ʯ • ʮಉ࣌ʹʯ • ʮͲ͏ૢ࡞͢Δ͔ʯ
Έ͍ͨͳಈ͖Λ࣮ݱͰ͖Δ
݁ՌΛݟΔ • ίϚϯυΛ࣮ߦ͢Δͱ͜Μͳ݁Ռ͕ग़Δ
݁ՌΛݟΔ • ίϚϯυΛ࣮ߦ͢Δͱ͜Μͳ݁Ռ͕ग़Δ Global: ɹશγφϦΦͷ݁Ռ GlobalҎԼ: • ֤γφϦΦͷ݁Ռ •
ϦμΠϨΫτφϯόϦϯά
࣮ߦ݁Ռ • શ݅ॲཧ͕ऴΘΔͱhtmlʹు͖ग़͞ΕΔ • ΤϥʔɾɺԠ࣌ؒ • ϦΫΤετͳͲ͕Θ͔Δ
Tips
Ϣʔβʔ੍ޚฤ
nਓΛಉ࣌ʹ্ཱͪ͛Δ atOnceUsers(n) ͜ͷ߹n=100
ඵؒnਓϢʔβʔ͕ΞΫηε constantUsersPerSec(n) during(t seconds) • n=100 • t=5 • 100ਓͣͭΞΫςΟϒ’Ϣʔβʔ͕૿͍͑ͯΔ
tඵͰϦΫΤετ͕nਓ·Ͱ૿Ճ rampUsers(n) during(t seconds) • n=100 • t=5 5ඵ͔͚ͯ100userʹͳΔ 20[user/s]Ͱۉ͞Ε͍ͯΔͷ͕Θ͔Δ
࣮ફɿෛՙΛ্͔͛ͯΒΩʔϓ 1. 100ϢʔβʔͰ։࢝ 2. 5ඵ͔͚ͯ200ਓ૿Ճ 3. ఆ300ਓͰ10ඵΩʔϓ
ศརͳૢ࡞
POSTͷϨεϙϯεΛอଘ͢Δ • ͋ΔAPIʹPOSTͯ͠ɺͦͷ݁ՌΛར༻͍ͨ͠ • saveAsͰσʔλΛอଘ • ࣦഊͨ͠߹exitHereIfFailedͰଈதஅ
body͋ΓͰPOST • bodyʹJSONΛ͚ͩ͢ • ؔԽ͓ͯ͘͠ͱศར
GETʢϨεϙϯεΛར༻ʣ • جຊతʹPOSTͱಉ͡ • session => ͰηογϣϯใΛར༻Մೳ • session(“hoge")ͰऔಘՄೳ
SessionʹΛอଘ • exec͔Βsession.setͰ֨ೲՄೳ • "${url}" ͰࢀরͰ͖ΔΑ͏ʹͳΔ
৭ʑ͍͚ͬͨͲ
खΛಈ͔͞ͳ͍ͱ Θ͔Μͳ͍ΑͶ
ԶͷΨτϦϯά
αϯϓϧ࡞Γ·ͨ͠ https://github.com/mochisuna/load-test-sample localhost:8080 localhost:3306 localhost:8000 POST: create_user GET: refer_user POST:
display_user
POST: Ϣʔβʔ࡞ localhost:8080 localhost:3306 localhost:8000
GET: Ϣʔβʔऔಘ localhost:8080 localhost:3306 localhost:8000
POST: ϦμΠϨΫτ localhost:8080 localhost:3306 localhost:8000
POST: ϦμΠϨΫτ localhost:8080 localhost:3306 localhost:8000
ՐΛͥ͘ खΛ৳ͯ͠ઓ͏ Πϯυਓ͕ೖͬͯ·ͨ͠
݁Ռ
࣮ߦ͢Δͱɾɾɾ • Redirect 1ͰࢮΜͰΔΘ • Nginx͕ࢮΜͰΜͳʔʢଞਓࣄʣ ͳͲ͕Θ͔Δ
࣮ࡍͷࢼݧͰͲ͏͔ͩͬͨ
flood.ioͰ࣮ફ Ͳ͕͜ ϘτϧωοΫ͔ ͙͢Θ͔Δ
݁ՌΛ౿·͑அ ࠓ·ͰɿʮͱΓ͋͑ͣ૿͠ͱ͖Ό͑͑Ζʯ ࠓճɿ • ʮnͰr [req/s]͍͚ͨʯ • ʮm%༨ʹεέʔϧΞτ͓͖ͯ͠·͠ΐ͏ʯ
݁ՌΛ౿·͑அ ࠓ·ͰɿʮͱΓ͋͑ͣ૿͠ͱ͖Ό͑͑Ζʯ ࠓճɿ • ʮnͰr [req/s]͍͚ͨʯ • ʮm%༨ʹεέʔϧΞτ͓͖ͯ͠·͠ΐ͏ʯ ఆྔతͳஅɾίετݮʂ
͜ͷ݁ՌΛ౿·͑ຊ൪ ɹɹɹɹɹ66,901݅ ɹɹɹɹɹ41,400݅ ɹɹɹɹɹ51,000݅ ɹɹɹɹɹ 6,750݅ ετΞ" ετΞ# ετΞ$ ετΞ%
͜ͷ݁ՌΛ౿·͑ຊ൪ ɹɹɹɹɹ66,901݅ ɹɹɹɹɹ41,400݅ ɹɹɹɹɹ51,000݅ ɹɹɹɹɹ 6,750݅ ετΞ" ετΞ# ετΞ$ ετΞ%
ແఀࢭͰ͍ग़͠ୡʂ
·ͱΊ • gatlingͭΑ͍ͧʔ͍ͧ͢͝ʔ • ෳࡶͳॲཧಛघͳϢʔβʔૢ࡞τϨʔεՄೳ • flood.ioศར • ్தͰόʔδϣϯ্͕Γ͕ͬͨ •
Scalaྗͳ͍͚ͯ͘Δ͚Ͳɺͨ·ʹσόοά͕େม • ಛʹsessionपΓ
ͦͷଞ • ຊAWSʹσϞڥݐ͔ͯͨͬͨ • ʮTerraformͰશࣗಈώϡʔʂʯͱ͔ͬͯͨΒ ࣌ؒͳ͘ͳͬͨ • αϯϓϧ࡞Δͷָ͔ͬͨ͠
ఆ࣭
ෛՙࢼݧΛ͢ΔλΠϛϯάʁ • ݱঢ়ɺׂͱରྍ๏త • खॱΛཱ֬͢Δͷʹίετ͔͔Δ͠ɾɾɾ • ຊCI/CDͱಉ͙͡Β͍ͷසʹ͍ͨ͠ • ଞͷاۀ͞Μͱ͔Ͳ͏ͯ͠ΔΜͩΖ͏ʁ
Ͳͷ͙Β͍ͷظؒͰ࣮ࢪͨ͠ʁ • ຊ൪ɿ12/5 • ෛՙࢼݧνʔϜൃɿ11/13 • طଘͷڥΛಉ͡ͷΛߏஙɿʙ11/19 • γφϦΦ࡞ɿʙ11/29ʢ͔ͳΓ٧·ͬͨɾɾɾʣ •
ෛՙࢼݧɿʙ12/5ʢ·ͰΘͪΌΘͪΌʣ
Ͳͷ͙Β͍ͷظؒͰ࣮ࢪͨ͠ʁ • ຊ൪ɿ12/5 • ෛՙࢼݧνʔϜൃɿ11/13 • طଘͷڥΛಉ͡ͷΛߏஙɿʙ11/19 • γφϦΦ࡞ɿʙ11/29ʢ͔ͳΓ٧·ͬͨɾɾɾʣ •
ෛՙࢼݧɿʙ12/5ʢ·ͰΘͪΌΘͪΌʣ ख࡞ۀͰݐͯͨڥͷෳ͕ࠈͩͬͨ
ͳΜͰgo • ॻ͖͔͚ͨͬͨͩ • αϯϓϧʹϚδʹͳΓͨ͘ͳ͔ͬͨ • ͜ͷنͷαϯϓϧͳΒָʹॻ͚ΔͰ͢ • ผʹීஈͬͯΔRailsʹർΕͨͱ͔ͦ͏͍͏ͷͰͳ͍ •
νϡʔχϯάͱ͔ͦͦΔؾͳ͔ͬͨ