performance testing · @gmuecke by the end of this workshop you should have a local test setup with...

59
@gmuecke Performance Testing WITH GATLING 1

Upload: others

Post on 20-Jul-2020

2 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Performance Testing · @gmuecke By the end of this Workshop You should have a local test setup with An example Application A Gatling Test Script Basic Monitoring So you could experiment

@gmuecke

Performance TestingWITH GATLING

1

Page 2: Performance Testing · @gmuecke By the end of this Workshop You should have a local test setup with An example Application A Gatling Test Script Basic Monitoring So you could experiment

@gmuecke

Workshop mission

Theory

What? Why? How?

Introduction to Gatling

Test Design

Structure

Load Modelling

(Diagnostics)

Practice

The Juice Shop Story

Record

Edit &

Execute Load Tests with

Gatling

2

Page 3: Performance Testing · @gmuecke By the end of this Workshop You should have a local test setup with An example Application A Gatling Test Script Basic Monitoring So you could experiment

@gmuecke

By the end of this Workshop

You should have a local test setup with

An example Application

A Gatling Test Script

Basic Monitoring

So you could experiment for yourself afterwards

You should know

How to create a Simulation using the Recorder (Record & Replay)

Waht the elements of a Gatling Load Test are

Know the Basics for Designing a Load Test

3

Page 4: Performance Testing · @gmuecke By the end of this Workshop You should have a local test setup with An example Application A Gatling Test Script Basic Monitoring So you could experiment

@gmuecke

How to do Performance Testing?

4

Page 5: Performance Testing · @gmuecke By the end of this Workshop You should have a local test setup with An example Application A Gatling Test Script Basic Monitoring So you could experiment

@gmuecke

Type of Load Test

Batch Online

5

• Process the most events in the

least time

• Event Driven

• Focus on Low Response Times

• Get the most done in the least time

and resources

• Data Driven

• Focus on Maximum Troughput

Page 6: Performance Testing · @gmuecke By the end of this Workshop You should have a local test setup with An example Application A Gatling Test Script Basic Monitoring So you could experiment

@gmuecke

Input to Load Test Scenarios

Performance Requirements

Target Users (Concurrent, per Duration, Total)

Response Time Targets (90%, 95%, 99%)

Throughput

Historical Data

Number of Total Users per Duration

Number of Concurrent Users

Peak Loads (Peak Month/Day/Hour/Minute)

Request Logs

Educated Guesses / Gut Feeling

6

Page 7: Performance Testing · @gmuecke By the end of this Workshop You should have a local test setup with An example Application A Gatling Test Script Basic Monitoring So you could experiment

@gmuecke

Example

Requirements

The system is capable of

Serving 1000 concurrent users with

an average Response Time of 1.5s

Source: The Project Manager

What are the most relevant

information?

This Photo by Unknown Author is licensed under CC BY-NC-SA

7

Page 8: Performance Testing · @gmuecke By the end of this Workshop You should have a local test setup with An example Application A Gatling Test Script Basic Monitoring So you could experiment

@gmuecke

Numbers need a Context

Concurrent Users (fit into CPU)

vs. Concurrent Sessions (fit into Memory)

vs. Users per Period (fit into System)

Average

vs. perceived Average (90 %)

vs. Percentiles (95%,99%,99.9%)

1000 Conc.Users, avg < 1.5s

vs 1000 Users/h, 90% < 1.5s

This Photo by Unknown Author is licensed under CC BY-NC-SA

8

Page 9: Performance Testing · @gmuecke By the end of this Workshop You should have a local test setup with An example Application A Gatling Test Script Basic Monitoring So you could experiment

@gmuecke

Load Testing Practices

Soak Testing

Discover Leaks

SLA Regressions

Stress Testing

Testing Stability

Overload / Recovery

Benchmarking

Discover Regressions between different Versions or Configurations

9

Page 10: Performance Testing · @gmuecke By the end of this Workshop You should have a local test setup with An example Application A Gatling Test Script Basic Monitoring So you could experiment

@gmuecke

A typical load test: Constant Load

Constant Load

+ Ramp up / down

Allowing the System to adapt to Load (warm up)

Distributes Load (virtual users)

Good for:

Finding latent bugs, i.e.Memory or Resource Leaks

Precise Measurements

Finding Regressions

Finding Stability Issues

Statistical Response Times

Known Load Distributions

Load

%

t

10

Page 11: Performance Testing · @gmuecke By the end of this Workshop You should have a local test setup with An example Application A Gatling Test Script Basic Monitoring So you could experiment

@gmuecke

Why do a ramp up?

System Warm-up

Allow JIT to optimize code

Allow Caches to be populated

Fetch or Initiate Resources

(i.e. Database Connections)

Allow Queues and Buffers to fill to a stable level

Distribute Load evenly

System’s Performance Characteristics arenon-linear during ramup

11

This Photo by Unknown Author is licensed under CC BY-NC-ND

Page 12: Performance Testing · @gmuecke By the end of this Workshop You should have a local test setup with An example Application A Gatling Test Script Basic Monitoring So you could experiment

@gmuecke

What do we test for?

Capacity

Oversubscribed resources

CPU

Memory

Bandwith

Storage

Queues

Response times under load

Stability

Resources leaks

Memory

Network connections

Filehandle

System crashes

System recovery

12

Page 13: Performance Testing · @gmuecke By the end of this Workshop You should have a local test setup with An example Application A Gatling Test Script Basic Monitoring So you could experiment

@gmuecke

Any Heuristics to sum it up?

13

Page 14: Performance Testing · @gmuecke By the end of this Workshop You should have a local test setup with An example Application A Gatling Test Script Basic Monitoring So you could experiment

@gmuecke

CCD IS EARI

Context: Project context is central to successful performance testing.

Criteria: Business, project, system, & user success criteria.

Design: Identify system usage, and key metrics; plan and design tests.

Install: Install and prepare environment, tools, & resource monitors.

Script: Implement test design using tools.

Execute: Run and monitor tests. Validate tests, test data, and results.

Analyze: Analyze the data individually and as a cross-functional team.

Report: Consolidate and share results, customized by audience.

Iterate: "Lather, rinse, repeat" as necessary.

14

http://scott-barber.blogspot.com/2007/05/performance-testing-core-principles-ccd.html

Page 15: Performance Testing · @gmuecke By the end of this Workshop You should have a local test setup with An example Application A Gatling Test Script Basic Monitoring So you could experiment

@gmuecke

IVECTRAS

INVESTIGATION or VALIDATION

of END-TO-END or COMPONENT

response TIMES and/or RESOURCE consumption

under ANTICIPATED or STRESSFUL conditions

15

http://scott-barber.blogspot.com/2007/08/this-is-second-installment-of-currently.html

Page 16: Performance Testing · @gmuecke By the end of this Workshop You should have a local test setup with An example Application A Gatling Test Script Basic Monitoring So you could experiment

@gmuecke

GatlingAN INTRODUCTION

16

Page 17: Performance Testing · @gmuecke By the end of this Workshop You should have a local test setup with An example Application A Gatling Test Script Basic Monitoring So you could experiment

@gmuecke

Gatling Basics

Written in Scala

And so are the Load Tests

Asynchronous, Non-Blocking, Event-Driven Concurrency Model

Virtual Users are «Messages», not threads

Less Resource Consumption & Higher Loads

Supports Open and Closes Workload Modells

Standalone or Integration with Maven / Gradle

Useful in Continuous Integration Pipelines

Visual Reports

17

Page 18: Performance Testing · @gmuecke By the end of this Workshop You should have a local test setup with An example Application A Gatling Test Script Basic Monitoring So you could experiment

@gmuecke

Pros & Cons

Pro

Testing Framework

Small, lightweight → reduced to

max

No installation:

Maven / Gradle Plugin

Download Standalone

Highly Scalable

Event Based Load Generation

Documentation & Community

Free & OpenSource

Cons

No UI

only for Recorder

Requires programming skills

Scala

Limited Protocol Support

HTTP & JMS

Basic reporting

18

Page 19: Performance Testing · @gmuecke By the end of this Workshop You should have a local test setup with An example Application A Gatling Test Script Basic Monitoring So you could experiment

@gmuecke

Threads vs EventsLOAD GENERATION BASICS

19

Page 20: Performance Testing · @gmuecke By the end of this Workshop You should have a local test setup with An example Application A Gatling Test Script Basic Monitoring So you could experiment

@gmuecke

Thread based Load Generation

Thread 1

Virtual User

20

Page 21: Performance Testing · @gmuecke By the end of this Workshop You should have a local test setup with An example Application A Gatling Test Script Basic Monitoring So you could experiment

@gmuecke

Thread based Load Generation

Thread 1

Request

Virtual User

21

Page 22: Performance Testing · @gmuecke By the end of this Workshop You should have a local test setup with An example Application A Gatling Test Script Basic Monitoring So you could experiment

@gmuecke

Thread based Load Generation

Thread 1

Thread WAIT

Virtual User

22

Page 23: Performance Testing · @gmuecke By the end of this Workshop You should have a local test setup with An example Application A Gatling Test Script Basic Monitoring So you could experiment

@gmuecke

Thread based Load Generation

Thread 1

Response

Virtual User

23

Page 24: Performance Testing · @gmuecke By the end of this Workshop You should have a local test setup with An example Application A Gatling Test Script Basic Monitoring So you could experiment

@gmuecke

Thread based Load Generation

Thread 1

Think Time

Virtual User

24

Page 25: Performance Testing · @gmuecke By the end of this Workshop You should have a local test setup with An example Application A Gatling Test Script Basic Monitoring So you could experiment

@gmuecke

Thread based Load Generation

Thread 1

User Scenario

Virtual User

25

Page 26: Performance Testing · @gmuecke By the end of this Workshop You should have a local test setup with An example Application A Gatling Test Script Basic Monitoring So you could experiment

@gmuecke

Thread based Load Generation

Thread 1

Pace time

Virtual User

26

Page 27: Performance Testing · @gmuecke By the end of this Workshop You should have a local test setup with An example Application A Gatling Test Script Basic Monitoring So you could experiment

@gmuecke

Thread based Load Generation

Thread 1

Virtual User

Real User 1 Real User 2

27

Page 28: Performance Testing · @gmuecke By the end of this Workshop You should have a local test setup with An example Application A Gatling Test Script Basic Monitoring So you could experiment

@gmuecke

Thread based Load Generation

Thread 1

Thread 2

28

Thread 3

Page 29: Performance Testing · @gmuecke By the end of this Workshop You should have a local test setup with An example Application A Gatling Test Script Basic Monitoring So you could experiment

@gmuecke

Thread based Load Generation

Characteristics

Each Simulated Real User depends on it’s previous user

Each consecutive Request depends on Response for previous Request

Requires lot of Resource

Suffers from Coordinated Omission (SUT throttles Load Generator)

Rampup ensures that generated load is evenly distributed

Pacing ensures that load distribution remains stable

Good for

Closed User Groups (i.e. Employees, Named Users), Dependant Users

Determine Capacity

Tool Example: Apache JMeter

29

Page 30: Performance Testing · @gmuecke By the end of this Workshop You should have a local test setup with An example Application A Gatling Test Script Basic Monitoring So you could experiment

@gmuecke

Event Based Load Generation

Event

Thread

Timer Event Response

Event

AsyncRequest

Async

Response

30

Page 31: Performance Testing · @gmuecke By the end of this Workshop You should have a local test setup with An example Application A Gatling Test Script Basic Monitoring So you could experiment

@gmuecke

Event Based Load Generation

Event

Thread

31

More

Users

Page 32: Performance Testing · @gmuecke By the end of this Workshop You should have a local test setup with An example Application A Gatling Test Script Basic Monitoring So you could experiment

@gmuecke

Event Based Load Generation

Characteristics

Simulated Users are Independent

Sent Requests are independent from previous Requests

Requests/Responses are handled asynchronously

Requires less resources for same load as thread based systems

No Coordinated Omission

Limited by the Processing Capacity of the Event-Thread

Ramp up / down is defined by change in User Rate

Good for

Independent Users

Open User Groups (i.e. for public web sites)

User Experience Rating

Tool-Example: Gatling

32

Page 33: Performance Testing · @gmuecke By the end of this Workshop You should have a local test setup with An example Application A Gatling Test Script Basic Monitoring So you could experiment

@gmuecke

Three

elements of

a Load Test

• How groups of usersnavigate throughyour application

User Flows

• How to fetch a typical page and it’sresources

Page Scripts

• How the users arrive at your page

Load Function

33

Page 34: Performance Testing · @gmuecke By the end of this Workshop You should have a local test setup with An example Application A Gatling Test Script Basic Monitoring So you could experiment

@gmuecke

Three

elements of

a Load Test

User Flows

Page Scripts

Load Function

34

GET /index.html

GET /favicon.ico

GET /someScript.js

GET /img/background.jpg

Page 35: Performance Testing · @gmuecke By the end of this Workshop You should have a local test setup with An example Application A Gatling Test Script Basic Monitoring So you could experiment

@gmuecke

Test Development with Gatling 35

Scenarios Load ModelsPages

Page 36: Performance Testing · @gmuecke By the end of this Workshop You should have a local test setup with An example Application A Gatling Test Script Basic Monitoring So you could experiment

@gmuecke

Test Development with Gatling 36

val page1 = exec(

http("request_0")

.get("/")

.headers(acceptHtml)

.resources(...))

Pages Scenarios

val scn =

scenario("Simple")

.exec(page1)

Load Models

scn.inject(

constantUsersPerSec(500)

during (1 minute)

)

Page 37: Performance Testing · @gmuecke By the end of this Workshop You should have a local test setup with An example Application A Gatling Test Script Basic Monitoring So you could experiment

@gmuecke

ExerciseRECORD & REPLAY SCRIPT WITH GATLING

37

Page 38: Performance Testing · @gmuecke By the end of this Workshop You should have a local test setup with An example Application A Gatling Test Script Basic Monitoring So you could experiment

@gmuecke

The Boutique de Jus story

We want to revolutionize the way people consume healthy food. We’re going to launch several service offerings, starting with ourultimate Juice-Shop.

Business goal:

Our investors expect profit at peak of 1.5Mio$ / month (30days)

Assuming a revenue 5$/order and profit margin of 10%

→ we need 100k orders per day

We expect 70k-100k visits on our site per hour.

We assume that all visits occur within 10 hours per day-

Conversion rate of 10% (submitted orders)

Response time per page should be 1.5s – 4s

38

Page 39: Performance Testing · @gmuecke By the end of this Workshop You should have a local test setup with An example Application A Gatling Test Script Basic Monitoring So you could experiment

@gmuecke

CCD IS EARI

Context: Startup, Webshop: boutique de jus

Criteria: 100k user/h, 10k orders/h, Response times: 1.5s-4s

Design: → see excercises

Install: → see excercise 1

Script: → see excercises

Execute: execute scripts & monitor with VisualVM

Analyze: see gatling reports & VisualVM

Report: create a brief report in exercise 3 using PROOF

Iterate: in three excercises

39

Page 40: Performance Testing · @gmuecke By the end of this Workshop You should have a local test setup with An example Application A Gatling Test Script Basic Monitoring So you could experiment

@gmuecke

Test Mission

Criteria:

Set the technical baseline

Are you able to test with Gatling?

Design: Record a very simple flow for load testing

Install: setup the test lab package on your machines

40

Page 41: Performance Testing · @gmuecke By the end of this Workshop You should have a local test setup with An example Application A Gatling Test Script Basic Monitoring So you could experiment

@gmuecke

Designing Performance Tests

41

Page 42: Performance Testing · @gmuecke By the end of this Workshop You should have a local test setup with An example Application A Gatling Test Script Basic Monitoring So you could experiment

@gmuecke

FIBLOTS

Frequent: Common application usage.

Intensive: i.e. Resource hogging activities.

Business Critical: Even if these activities are both rare and not risky

Legal: Stuff that will get you sued or not paid.

Obvious: Stuff that is likely to earn you bad press

Technically Risky: New technologies, old technologies, places where

it’s failed before, previously under-tested areas

Stakeholder Mandated: Don’t argue with the boss (too much).

42

http://scott-barber.blogspot.com/2011/09/model-workloads-for-performance-testing.html

Page 43: Performance Testing · @gmuecke By the end of this Workshop You should have a local test setup with An example Application A Gatling Test Script Basic Monitoring So you could experiment

@gmuecke

What is a Load Model?

How Load is distributed over time

Defined by a rate of events in a period

Users arriving at the application

Requests

Actions / Clicks

Bytes

43

Page 44: Performance Testing · @gmuecke By the end of this Workshop You should have a local test setup with An example Application A Gatling Test Script Basic Monitoring So you could experiment

@gmuecke

Equi-Distribution

Completely Synthetic

Suitable for

long-running stability Tests

Benchmarking

Load should aim at 80% systemcapacity

Good for tracking long-term effects

Resource / Memory Leaks

Gargbage Collection Singularities

Native support in Gatling

44

Page 45: Performance Testing · @gmuecke By the end of this Workshop You should have a local test setup with An example Application A Gatling Test Script Basic Monitoring So you could experiment

@gmuecke

Ramp-up

Slowly increasing Load on System

System can Warm-up

Populate Caches

Compile & Optimize Code (Java ->

JIT)

Users & Requests get distributed

Native support in Gatling

45

Page 46: Performance Testing · @gmuecke By the end of this Workshop You should have a local test setup with An example Application A Gatling Test Script Basic Monitoring So you could experiment

@gmuecke

Open vs Closed Workload

Open

Load Generator and System Under

Test have no Feedback Loop

SUT can be overloaded

Modelled by Arrival Rate

Suitable for Unknown User Group

and Statistical Distributions

Supported by Gatling

Closed

Load Generator and System under

Test in a Feedback Loop

SUT throttles LG

Load System establishes a balance

Modelled by Concurrent Users

Suitable for Closed User Groups

and Known Loads

Since Gatling 3.0

46

Page 47: Performance Testing · @gmuecke By the end of this Workshop You should have a local test setup with An example Application A Gatling Test Script Basic Monitoring So you could experiment

@gmuecke

Analysis &

Reporting

48

Photo: Calvinius

Page 48: Performance Testing · @gmuecke By the end of this Workshop You should have a local test setup with An example Application A Gatling Test Script Basic Monitoring So you could experiment

@gmuecke

What do we need for a deeper analysis?

Precise reporting of your observations

Baseline configuration of the system

Model of the system (architecture) to visualize the flow

The right people available

49

Page 49: Performance Testing · @gmuecke By the end of this Workshop You should have a local test setup with An example Application A Gatling Test Script Basic Monitoring So you could experiment

@gmuecke

External Observations

Response Times

Averages, Min, Max

Percentile (90% is perceived average!)

Outliers

Histogram

Error Responses

Which page fails most often?

Live Uses (Users that have not finished their scenario)

Piling up?

Constant

50

Page 50: Performance Testing · @gmuecke By the end of this Workshop You should have a local test setup with An example Application A Gatling Test Script Basic Monitoring So you could experiment

@gmuecke

Internal Observations

CPU Consumption

System

I/O Activity

Disc

Network

Context Switching

User

Threads & Contention

GC Activity

Algorithms

Hardware Counters

Garbage Collection Activity

GC Logs

Allocation Rates

GC Generational Behavior

Memory Consumption

Heap

Non-Heap

Thread Stacks

Direct Allocations

Code Cache

Metaspace

Leaks

51

Page 51: Performance Testing · @gmuecke By the end of this Workshop You should have a local test setup with An example Application A Gatling Test Script Basic Monitoring So you could experiment

@gmuecke

Java Performance:

Diagnostic Model*

Hardware/OS

JVM

Application

Usage Patterns / Actors

52

@kcpeppe

Dynamics

No Dynamics

Page 52: Performance Testing · @gmuecke By the end of this Workshop You should have a local test setup with An example Application A Gatling Test Script Basic Monitoring So you could experiment

@gmuecke

Java Performance:

Diagnostic Process

Application

JVM

Threads

System CPU: sys > 10% user?

User <100%?

Memory efficient? GC Logs

App/CPU Profiling

53

IO, Disk, Network,…

system profiling: netstat,

mpstat, iostat, sar, strace, ...

Thread Dump

Thread Starvation

GC Tuning, Collectors, Pool Sizes,

Memory Profiling, Frequency,

Lifespan …

CPU Profiling

Algorithms & Data Structures

@kcpeppe

Page 53: Performance Testing · @gmuecke By the end of this Workshop You should have a local test setup with An example Application A Gatling Test Script Basic Monitoring So you could experiment

@gmuecke

Reporting: PROOF

Past. What happened during the session?

Results. What was achieved during the session?

Obstacles. What got in the way of good testing?

Outlook. What still needs to be done?

Feelings. How does the tester feel about all this?

54

http://www.satisfice.com/articles/sbtm.pdf

Page 54: Performance Testing · @gmuecke By the end of this Workshop You should have a local test setup with An example Application A Gatling Test Script Basic Monitoring So you could experiment

@gmuecke

Summary

55

Page 55: Performance Testing · @gmuecke By the end of this Workshop You should have a local test setup with An example Application A Gatling Test Script Basic Monitoring So you could experiment

@gmuecke

Warning!

THE NEXT SLIDE CONTAINS A FLASHY PICTURE!

VIEWER DISCRETION IS ADVISED.

56

Page 56: Performance Testing · @gmuecke By the end of this Workshop You should have a local test setup with An example Application A Gatling Test Script Basic Monitoring So you could experiment

@gmuecke

57

Forget everything what you have heard so far, now comes the real important stuff!

Page 57: Performance Testing · @gmuecke By the end of this Workshop You should have a local test setup with An example Application A Gatling Test Script Basic Monitoring So you could experiment

@gmuecke

Test Development with Gatling 58

Scenarios Load ModelsPages

Page 58: Performance Testing · @gmuecke By the end of this Workshop You should have a local test setup with An example Application A Gatling Test Script Basic Monitoring So you could experiment

@gmuecke

Test Development with Gatling 59

val page1 = exec(

http("request_0")

.get("/")

.headers(acceptHtml)

.resources(...))

Pages Scenarios

val scn =

scenario("Simple")

.exec(page1)

Load Models

scn.inject(

constantUsersPerSec(500)

during (1 minute)

)

Page 59: Performance Testing · @gmuecke By the end of this Workshop You should have a local test setup with An example Application A Gatling Test Script Basic Monitoring So you could experiment

# BaselOne18