55
Stéphane Landelle & Pierre Dal- Pra eBusiness Information, Groupe Excilys Performance & Load Testing

Gatling, faites tomber la foudre

Embed Size (px)

DESCRIPTION

Présentation de l'outil de test de charge Gatling à l'AlpesJUG le 4 mars 2013 par Pierre Dalprat et Stéphane Landelle

Citation preview

Page 1: Gatling, faites tomber la foudre

Stéphane Landelle & Pierre Dal-Pra

eBusiness Information,Groupe Excilys

Performance & Load Testing

Page 2: Gatling, faites tomber la foudre

Part 1Concepts

Page 3: Gatling, faites tomber la foudre

Define performance?

• fast?• robust?• resource effective?

=> Define your requirements!

Page 4: Gatling, faites tomber la foudre

Web speed is a user experience

• < 0,5 s : loading looks instantaneous

• 0,5-2 s : not instantaneous, but acceptable

• > 3 s : users start leaving your site

Page 5: Gatling, faites tomber la foudre

Put things into perspective

Product Owner requirement :

Every page should show up under 500ms

WRONG !

User expectations = per use case!

Page 6: Gatling, faites tomber la foudre

Speed matters

• More traffic

• Better conversion rate

• Less angry users

Page 7: Gatling, faites tomber la foudre

Some figures

Google :Results/page : 10 => 30

-> +500 ms

-> -20% pages seen

Amazon :+100 ms

-> -1 % sales

estimated annual cost : $160M

Page 8: Gatling, faites tomber la foudre

Load tests : why ?

Load tests

=

Anticipate production problems

+

Train yourself on your app & infrastructure

Page 9: Gatling, faites tomber la foudre

Methodology

Clicking everywhere/Selenium = not a load test !

• You expect more than 1 user

• "Seems fast enough." => Not a metric !

Page 10: Gatling, faites tomber la foudre

Methodology

Comes after proper local perf testing

• Client/Network optimization: minification, javascript, sprites, caching...o Tools : Chrome Developer Tools, YSlow, Google

PageSpeed Insights...

• Application debugging: 50 SQL queries/page = BUG!o Tools : VisualVM, Yourkit, JProfiler, MAT...

Page 11: Gatling, faites tomber la foudre

Methodology

• Analyze = Data = Monitoring

• Fix hotspot

=> Iterate!

Page 12: Gatling, faites tomber la foudre

Tooling

• Load injector: Gatling, JMeter, Locust.io...

• JVM monitoring: JMXtrans, Yammer Metrics...

• System monitoring: Nagios

• Network monitoring

• Database monitoring

• Dashboard: Graphite, Ganglia

• Webapp mock: H. Gomez's basic perf webapp

Page 13: Gatling, faites tomber la foudre

Types of load tests

• Capacity Test

• Stress Test

• Endurance Test

Page 14: Gatling, faites tomber la foudre

Capacity Test

Goal : Determine how much load your system can hold

How :Repeat the same scenario over and over, but add virtual

users every time until performance starts degrading.

Page 15: Gatling, faites tomber la foudre

A response time under 1 s is expected

-> user cap : 1500 users

Page 16: Gatling, faites tomber la foudre

Stress Test

Goal :Study system behavior in case of heavy load, during AND

after

How : Find the max load your system can handle, and then run

the scenario with a heavier load.

Page 17: Gatling, faites tomber la foudre

10k users for 1 min, then 1k : webapp struggles, but stabilizes

Page 18: Gatling, faites tomber la foudre

Endurance Test

Goal :Validate system behavior after a long period of activity.

How :Run the scenario with a manageable load, but for a long

period of time (several hours at least).

Page 19: Gatling, faites tomber la foudre

Fast memory leak :Runs fine for 2 minutes until heap's full...

Page 20: Gatling, faites tomber la foudre

Ramps

Start virtual users progressively, because that's what real users do !

Ramps also help to warm up your system.

Page 21: Gatling, faites tomber la foudre

Reports

The purpose of load injectors : stress your app and produces reports

• Meaningful reports help developers analyze stress tests results and what to make of them

• Something shiny to give to your boss

Page 22: Gatling, faites tomber la foudre

The good, the bad and the ugly metrics

Every metric can be useful, but some less than others...

• Response time min/max = worst case/best case

• Mean can be biased in case of extreme values

Response time is a physical phenomenon

=> Statistically distributed

Page 23: Gatling, faites tomber la foudre
Page 24: Gatling, faites tomber la foudre

Percentiles to the rescue

nth percentiles

=

n % of users' response time

Page 25: Gatling, faites tomber la foudre

Part of the development process

Like functional testing, load testing should be :

• integrated early in the development cycle

• automated

• versioned

Page 26: Gatling, faites tomber la foudre

Part 2Gatling

Page 27: Gatling, faites tomber la foudre

Yet Another Stress Tool

JMeter, Grinder, Tsung, LoadUI,

LoadRunner, Neoload…

Page 28: Gatling, faites tomber la foudre

High PerformanceIssue #1

http://www.shopfbparts.com/catalog/nal-19201331_w.jpg

Page 29: Gatling, faites tomber la foudre

1 user = 1 thread

Page 30: Gatling, faites tomber la foudre

With 50 threads on a JVM

Page 31: Gatling, faites tomber la foudre

With 2000 threads on a JVM

Page 32: Gatling, faites tomber la foudre

Blocking I/O

Page 33: Gatling, faites tomber la foudre

Threads? Waiting…

Page 34: Gatling, faites tomber la foudre

… and sleeping

Page 35: Gatling, faites tomber la foudre

Is that a real problem?

Page 36: Gatling, faites tomber la foudre

Can you trust your results?

JMeter 2.8 perf test, expecting 300 tr/sec

Page 37: Gatling, faites tomber la foudre

UsabilityIssue #2

Page 38: Gatling, faites tomber la foudre

Listen, it's not that complicated...

Graphical User Interface

Page 39: Gatling, faites tomber la foudre

MaintainabilityIssue #3

Page 40: Gatling, faites tomber la foudre

What was this change about?

Page 41: Gatling, faites tomber la foudre

Gatling can change all that!

Page 42: Gatling, faites tomber la foudre

Version 1.4.3Released February 2013

Say hello to my little friend…

Page 43: Gatling, faites tomber la foudre

Be asynchronous, embrace the actor model

Page 44: Gatling, faites tomber la foudre

Use non-blocking I/O

• Async HTTP Client• Netty

Page 45: Gatling, faites tomber la foudre

Scenario = Code (Scala) = DSL

Page 46: Gatling, faites tomber la foudre

Easy

Page 47: Gatling, faites tomber la foudre

Use the rich DSL…

Checks

• regex / css / xpath / jsonPath

• find / findAll / count

• is / in / not / whatever

Structures

• doIf / repeat / during / asLongAs

• randomSwitch / roundRobinSwitch

Error handling

• tryMax / exitBlockOnFail

Feeders

• csv / tsv / jdbc

Page 48: Gatling, faites tomber la foudre

… or write your own Scala code…

Page 49: Gatling, faites tomber la foudre

…or use the Recorder

Page 50: Gatling, faites tomber la foudre

Integrations• Maven Plugin• Maven archetype (run in IDE)

• Jenkins plugin

• Graphite live reporting

Page 51: Gatling, faites tomber la foudre

Coming soon…

• Websockets, JDBC…• Clustering

Page 52: Gatling, faites tomber la foudre

Part 3Demo

Page 53: Gatling, faites tomber la foudre

Conclusion

Page 54: Gatling, faites tomber la foudre

Really efficient?

Jmeter perf test run with Gatling, expecting 300 tr/sec

Page 55: Gatling, faites tomber la foudre

http://gatling-tool.org

https://github.com/excilys/gatling

@GatlingTool

https://github.com/slandelle

@slandelle

https://github.com/pdalpra

@pierre_dalpra