performance and stability testing \w gatling

84
With Gatling Performance & Stability Testing

Upload: dmitrijs-vrublevskis

Post on 17-Feb-2017

291 views

Category:

Technology


3 download

TRANSCRIPT

Page 1: Performance and stability testing \w Gatling

With Gatling

Performance & Stability Testing

Page 2: Performance and stability testing \w Gatling

Development Testing

Page 3: Performance and stability testing \w Gatling
Page 4: Performance and stability testing \w Gatling

@MeDmitry Vrublevsky, Software developer @

/in/dmitryvrublevsky

Page 5: Performance and stability testing \w Gatling

Roadmap

- Mission overview

- Gatling introduction

- Some usage example

Page 6: Performance and stability testing \w Gatling

Mission

Page 7: Performance and stability testing \w Gatling

Given: Graph database (Neo4j)

Challenge: execute query as FAST as we can

Page 8: Performance and stability testing \w Gatling

Neo4j

- Written in Java

- Native graph storage

- Extendable

Page 9: Performance and stability testing \w Gatling
Page 10: Performance and stability testing \w Gatling

So?

- Default API is too slow

- Implement custom extension

- Control all the things

Page 11: Performance and stability testing \w Gatling

1. Developed

2. Deployed

3. ???

4. Success!

Page 12: Performance and stability testing \w Gatling
Page 13: Performance and stability testing \w Gatling

Performance

Page 14: Performance and stability testing \w Gatling

Specification

Do “X” operations

in “Y” seconds

Page 15: Performance and stability testing \w Gatling

Specification

Do “10000” query operations

in “10” seconds

Page 16: Performance and stability testing \w Gatling

POST /extension/query Body: “MATCH (root)-[:HAS*]->(child)”

Response: { // JSON data }

Page 17: Performance and stability testing \w Gatling

Client

LB

DB1 DB2 DB3

- our extension

Page 18: Performance and stability testing \w Gatling

Problems?

Page 19: Performance and stability testing \w Gatling

Client

LB

DB1 DB2 DB3

- our extension- possible problem

Page 20: Performance and stability testing \w Gatling

Gatling

http://gatling.io

Page 21: Performance and stability testing \w Gatling

Load testing framework

Page 22: Performance and stability testing \w Gatling

Free & Open source

Page 23: Performance and stability testing \w Gatling

High performance

Page 24: Performance and stability testing \w Gatling
Page 25: Performance and stability testing \w Gatling

Friendly DSL

Nice html reports

Page 26: Performance and stability testing \w Gatling

Coding ?

Page 27: Performance and stability testing \w Gatling

Bundle

1. Download bundle 2. Extract 3. Ready

http://gatling.io/#/download

Page 28: Performance and stability testing \w Gatling

Optional

- Maven integration - SBT plugin - Gradle plugin

Page 29: Performance and stability testing \w Gatling

package com.neueda.exampleimport io.gatling.core.Predef._import io.gatling.http.Predef._import scala.concurrent.duration._class Example extends Simulation { val httpConf = http.baseURL("http://www.example.com") val example = scenario("Example") .exec( http("get_example_index") .get("/") .check(status.is(200)) ) setUp( example.inject(rampUsers(10) over (10 seconds)) ).protocols(httpConf) }

Page 30: Performance and stability testing \w Gatling

package com.neueda.exampleimport io.gatling.core.Predef._import io.gatling.http.Predef._import scala.concurrent.duration._

Page 31: Performance and stability testing \w Gatling

class Example extends Simulation {}

Page 32: Performance and stability testing \w Gatling

val httpConf = http.baseURL("http://www.example.com")

Page 33: Performance and stability testing \w Gatling

val example = scenario("Example")

Page 34: Performance and stability testing \w Gatling

http("get_example_index") .get("/") .check(status.is(200))

Page 35: Performance and stability testing \w Gatling

setUp().protocols(httpConf)

Page 36: Performance and stability testing \w Gatling

example.inject( rampUsers(10) over (10 seconds) )

Page 37: Performance and stability testing \w Gatling

package com.neueda.exampleimport io.gatling.core.Predef._import io.gatling.http.Predef._import scala.concurrent.duration._class Example extends Simulation { val httpConf = http.baseURL("http://www.example.com") val example = scenario("Example") .exec( http("get_example_index") .get("/") .check(status.is(200)) ) setUp( example.inject(rampUsers(10) over (10 seconds)) ).protocols(httpConf) }

Page 38: Performance and stability testing \w Gatling

http://gatling.io/docs/2.1.4/cheat-sheet.html

Page 39: Performance and stability testing \w Gatling

================================================================================2015-04-07 23:02:54 5s elapsed---- Example -------------------------------------------------------------------[##################################### ] 50% waiting: 5 / running: 0 / done:5---- Requests ------------------------------------------------------------------> Global (OK=5 KO=0 )> get_example_index (OK=5 KO=0 )================================================================================

================================================================================---- Global Information --------------------------------------------------------> request count 10 (OK=10 KO=0 )> min response time 255 (OK=255 KO=- )> max response time 302 (OK=302 KO=- )> mean response time 274 (OK=274 KO=- )> std deviation 13 (OK=13 KO=- )> response time 95th percentile 293 (OK=293 KO=- )> response time 99th percentile 300 (OK=300 KO=- )> mean requests/sec 1.08 (OK=1.08 KO=- )---- Response Time Distribution ------------------------------------------------> t < 800 ms 10 (100%)> 800 ms < t < 1200 ms 0 ( 0%)> t > 1200 ms 0 ( 0%)> failed 0 ( 0%)================================================================================

Page 40: Performance and stability testing \w Gatling

================================================================================2015-04-07 23:02:54 5s elapsed---- Example -------------------------------------------------------------------[##################################### ] 50% waiting: 5 / running: 0 / done:5---- Requests ------------------------------------------------------------------> Global (OK=5 KO=0 )> get_example_index (OK=5 KO=0 )================================================================================

================================================================================---- Global Information --------------------------------------------------------> request count 10 (OK=10 KO=0 )> min response time 255 (OK=255 KO=- )> max response time 302 (OK=302 KO=- )> mean response time 274 (OK=274 KO=- )> std deviation 13 (OK=13 KO=- )> response time 95th percentile 293 (OK=293 KO=- )> response time 99th percentile 300 (OK=300 KO=- )> mean requests/sec 1.08 (OK=1.08 KO=- )---- Response Time Distribution ------------------------------------------------> t < 800 ms 10 (100%)> 800 ms < t < 1200 ms 0 ( 0%)> t > 1200 ms 0 ( 0%)> failed 0 ( 0%)================================================================================

Page 41: Performance and stability testing \w Gatling

Reports \o/

Page 42: Performance and stability testing \w Gatling
Page 43: Performance and stability testing \w Gatling
Page 44: Performance and stability testing \w Gatling
Page 45: Performance and stability testing \w Gatling
Page 46: Performance and stability testing \w Gatling

class Test extends Simulation { val httpConf = http.baseURL("http://neo-database:7474") val test = scenario("GetGraph") .exec( http("execute_query") .post("/extension/query/execute") .body(StringBody("MATCH (root)-[:HAS*]->(child)")) .check(status.is(200)) .check(jsonPath("$.results").count.is(100)) ) setUp( test.inject( rampUsersPerSec(0) to (1000) during (60 seconds) ) ).protocols(httpConf) }

Page 47: Performance and stability testing \w Gatling

http("execute_query") .post( "/extension/query/execute" ) .body(StringBody( "MATCH (root)-[:HAS*]->(child)" )) .check( status.is(200) ) .check( jsonPath("$.results").count.is(100) )

1

2

3

4

Page 48: Performance and stability testing \w Gatling

rampUsersPerSec(0) to (1000) during (60 seconds)

Page 49: Performance and stability testing \w Gatling

Req

uest

s / S

econ

d

0

150

300

450

600

Seconds

0 10 20 30 40 50 60

Page 50: Performance and stability testing \w Gatling
Page 51: Performance and stability testing \w Gatling

When request/second goes up

And some threshold reached

Then we receive Timeout error

Page 52: Performance and stability testing \w Gatling

Everything is ok?

Maybe we can do higher load?

How to spot the problem?

Page 53: Performance and stability testing \w Gatling

Drop all

non-essential

parts

Page 54: Performance and stability testing \w Gatling

Client

LB

DB1 DB2 DB3

- our extension

Page 55: Performance and stability testing \w Gatling

0

250

500

750

1000

0 10 20 30 40 50 60

Page 56: Performance and stability testing \w Gatling
Page 57: Performance and stability testing \w Gatling

Client - Server communication

problems

Page 58: Performance and stability testing \w Gatling

• Incorrect server setup

• Unconfigured networking

• Low max open connection limit

Page 59: Performance and stability testing \w Gatling

Learned

- Performance testing should be done - Test results should be interpreted

properly - Test results should be verified in

different environments

Page 60: Performance and stability testing \w Gatling

We need to test different queries

Feeders!

Page 61: Performance and stability testing \w Gatling

val feeder = Array( Map("query" -> "..."), Map("query" -> "..."), Map("query" -> "...") )

.queue

.random

.circular

Page 62: Performance and stability testing \w Gatling

val test = scenario(“GetGraph") .feed(feeder) .exec(http("execute_query") .post("/extension/query/execute") .body(StringBody("${query}")) .check(status.is(200)) .check(jsonPath("$.results").count.is(100)) )

Page 63: Performance and stability testing \w Gatling

CSV JSON JDBC

Sitemap Redis

Custom

http://gatling.io/docs/2.1.4/session/feeder.html

Page 64: Performance and stability testing \w Gatling

csv("data.csv").random

Page 65: Performance and stability testing \w Gatling

Our own feeder

- Custom feeder - Lazy loads data - Performant

Page 66: Performance and stability testing \w Gatling

Dynamic user load?

http://gatling.io/docs/2.1.4/general/simulation_setup.html

Page 67: Performance and stability testing \w Gatling

test.inject( nothingFor(5 seconds),

atOnceUsers(10),

rampUsersPerSec(10) to (100) during (20 seconds),

constantUsersPerSec(100) during (40 seconds),

rampUsersPerSec(100) to (500) during (20 second),

constantUsersPerSec(100) during (60 seconds))

Page 68: Performance and stability testing \w Gatling

Checks

http://gatling.io/docs/2.1.4/http/http_check.html

Page 69: Performance and stability testing \w Gatling

- status - currentLocation - header - regex - xpath - jsonPath

Page 70: Performance and stability testing \w Gatling

regex("Invalid Page title").notExists

status.is(200)

jsonPath("$.posts").exists

regex("""<div class="article">""").count.is(10)

Page 71: Performance and stability testing \w Gatling

Realtime monitoring

http://gatling.io/docs/2.1.4/realtime_monitoring/index.html

Execution progress visual feedback

Page 72: Performance and stability testing \w Gatling

Graphite (InfluxDB) +

Grafana

Page 73: Performance and stability testing \w Gatling
Page 74: Performance and stability testing \w Gatling

Recorder

http://gatling.io/docs/2.1.4/http/recorder.html

Page 75: Performance and stability testing \w Gatling
Page 76: Performance and stability testing \w Gatling

HTTP

http://gatling.io/docs/2.1.4/http/recorder.html

- HTTP Protocol - SSL - WebSocket - SSE

Page 77: Performance and stability testing \w Gatling

Jenkins integration

https://github.com/jenkinsci/gatling-plugin

Page 78: Performance and stability testing \w Gatling

- Any IDE with Scala support is OK

- Intellij IDEA

- Eclipse (Scala IDE)

- Netbeans

Page 79: Performance and stability testing \w Gatling

Our use cases

Page 80: Performance and stability testing \w Gatling

GET /api/node/1 POST /api/node UPDATE /api/node

Basic API tests

Page 81: Performance and stability testing \w Gatling

- Generate background load - Make stability tests

- Cluster communications - Load balancer setup - Spikes

Load generator

Page 82: Performance and stability testing \w Gatling

- Simulate significant write load - Check how database reacts

Data import

Page 83: Performance and stability testing \w Gatling

Easy Fun

Performant

Page 84: Performance and stability testing \w Gatling