1 of 78

This is a presentation template.

It's intended to help you create your own presentation. Feel free to take the slides you want and delete the rest!

Please do not make changes directly in this deck– make a copy of it and modify to fit your use case.

These slides are a work in progress. If you have any feedback, join the public Grafana Slack and let us know in the #k6 channel.

2 of 78

Introduction to k6

Your Name

Your Role at Your Company

3 of 78

What is load testing?

What is k6?

How to integrate and extend k6

How k6 fits into the Grafana Labs vision

k6.io

Overview

1

2

3

4

5

4 of 78

What is load testing?

5 of 78

"Load testing is the process of putting demand on a system and measuring its response."

6 of 78

Load

Testing

✅ ❌

7 of 78

Load

Testing

Accept Errors: 9s of Reliability

Accept Outliers: percentiles 90/95/99/..

8 of 78

“Load testing is the process of putting demand on a system and measuring its response”

9 of 78

What is load testing?

10 of 78

“Load testing is the process of putting demand on a system and measuring its response

Scalability/Elasticity 📈

Resilience 💥

Availability 🟢

Reliability ✔️

Latency 🏎️

11 of 78

“Applications and Systems perform differently under [distinct] traffic“

12 of 78

Common types of load tests

Breakpoint test

Spike test

Soak test

Average and peak test

13 of 78

Common types of load tests

Test Load

Test Duration

Smoke tests

Average load tests

Stress tests

Spike tests

Soak tests

Breakpoint tests

14 of 78

Why do load testing?

15 of 78

Myths about load testing

  • Performance testing = load testing.
  • Load testing is only for large companies.
  • Load testing is expensive.
  • Load testing should only be done in production.
  • You don't need load testing if you have observability.

16 of 78

Why do load testing today?

UX

17 of 78

Why load testing today?

Distributed systems

18 of 78

Why load testing today?

SLOs - Reliability

Be proactive

19 of 78

Why load testing today?

Fragility

Embrace and Prevent Failures

20 of 78

Modern testing

Why k6?

21 of 78

Release frequency

How is initiated

Testing environment

Testing frequency

PT Checklist / OLD WAY

Before releases

Test and Production

Manually

Quarterly or biannually

Modern testing. Why k6?

QA bottleneck

Lower Test Coverage

22 of 78

Test Often - Continuous Testing

Release frequency

How is initiated

Testing environment

Testing frequency

DevOps / MODERN WAY

Weekly

AND nightly, feature branches, continuous, synthetic monitoring

Scheduled. Automatically as part of CI/CD

AND Staging, Long-lived and Short-lived ephemerals environment

PT Checklist / OLD WAY

Before releases

Test and Production

Manually

Quarterly or biannually

Modern testing. Why k6?

23 of 78

Iterative:

Start simple

Modern testing. Why k6?

24 of 78

Team Effort

Modern testing. Why k6?

25 of 78

Modern testing. Distributed systems

End-to-end

Integration

Component

Browser / HTTP / WS

HTTP / gRPC / SQS

26 of 78

Modern testing. Distributed systems

Store

(PostgreSQL)

Frontend

Proxy

API

Feature Flag

Ads

Payment

Accounting

Fraud Detection

Cart

Currency

Email

Recommendations

Quote

Products

Checkout

Shipping

Queue

(Kafka)

Cache

(Redis)

Protocols

HTTP gRPC TCP Other

Services

Technologies

Java

JavaScript

Kotlin

PHP

.NET

C++

Erlang

Go

Python

Ruby

Rust

27 of 78

Modern load testing

End-to-end

Integration

Component

Scalability

Resilience

Availability

Reliability

Latency

Breaking

Soak

Stress

Spike

Average

Dev/QA

Pre-prod

Production

28 of 78

Start Simple and Test Frequently.

Fail Early.

Make Reliability a Team effort.

29 of 78

What is k6?

Free and open source tool

Paid performance testing platform

30 of 78

Open source

Same k6 test script for multiple execution modes

👉

31 of 78

Test as Code - Programmable

32 of 78

Test as Code - Programmable

33 of 78

Test as Code - Programmable

pre-release env.

production env.

Average load

Stress load

Nightly test

📉⚠️

🎯✅

34 of 78

Limitations with NodeJS and browser libraries

40K VUs in one load generator

JAVASCRIPT RUNTIME

GOJA

GOLANG

*.js / *.ts

Performant

35 of 78

Protocols

Outputs

Use cases

Extensible

InfluxDB

Prometheus

TimescaleDB

Grafana Cloud

NewRelic

Dynatrace

….

HTTP

Websocket

SQL / NoSQL

AMQP / Kafka

Crypto

Redis

….

Browser testing

Infrastructure testing

Chaos testing

JAVASCRIPT RUNTIME

GOJA

GOLANG

xk6 EXTENSIONS

….

36 of 78

k6 Concepts

37 of 78

CLI flags

ENV variables

Script options

Default

Config file

Order of preference

Scenarios: Options

38 of 78

VU

Iterations

Scenario

VU

While (true) {� runScenario();�}

VU

While (true) {� runScenario();�}

VU

VU

While (true) {� runScenario();�}

VU

While (true) {� runScenario();�}

Duration

39 of 78

Built-in Metrics

Custom Metrics

new Trend(‘metric_name’);

new Rate(‘metric_name’);

new Counter(‘metric_name’);

new Gauge(‘metric_name’);

40 of 78

Checks

Thresholds

Like Unit testing, for Performance

41 of 78

Multiple Scenarios

Constant Arrival Rate

Ramping Arrival Rate

Per VU iterations

Ramping VUs

Shared iterations

Constant VUs

42 of 78

As Code ⚡CodeLess

43 of 78

K6 Studio

👩‍💻

🌐

Response Correlation

Variable Parameterization

VU Data

Parameterization

44 of 78

Session recording

👩‍💻

🌐

HAR file

HAR to k6 Converter

Response Correlation

Variable Parameterization

VU Data

Parameterization

45 of 78

Open API Converter

$ openapi-to-k6 petstore-api.yaml petstore-test.ts

$ k6 run petstore-test.ts

46 of 78

Test data

SharedArray Best performant for larger arrays of data: CSV, JSON, ….

Faker Generate realistic data at runtime

47 of 78

Much more in

k6 docs

📚

48 of 78

Extensible (Full-stack / Hybrid testing)

49 of 78

Mimic Playwright API

Webvital metrics

k6 Browser 📚

50 of 78

Infrastructure testing / benchmarking

xk6-amqp

xk6-kafka

xk6-amqp

xk6-ethereum

xk6-celery

k6 extension JS API

k6 extension (GO)

xk6-sql

….

51 of 78

Failure Injection Testing

“From the distributed systems perspective, almost all interesting availability experiments can be driven by affecting latency or

response type

Chaos Engineering: System Resiliency in Practice.

👤

52 of 78

Full-stack / hybrid performance testing

End to end browser test

News API: average load test

53 of 78

Performance Testing

54 of 78

Full-stack / hybrid performance testing

Account API: 100ms delay

End to end browser test

News API: average load test

UI

News

Account

🏋️

💣

👤

55 of 78

k6 Results

56 of 78

57 of 78

Terminal

Web dashboard

Visualization

Storage

k6 run script.js -o output-xyz

k6 run script.js

k6 Results

58 of 78

59 of 78

Healthy performance looks flat

60 of 78

Validate

SLOs and Quality gates

Test

result

Baseline

comparison

Correlate

with

system’s

data

Test

comparison

61 of 78

What’s Grafana Cloud k6?

62 of 78

When Grafana Cloud k6 fits

scale,

UX,

instant,

managed,

flexibility

dashboards,

role access,

projects,

activity,

collaboration

dashboards,

baselines,

test comparisons,

storage,

integrations

Convenience

Better for teams

Continuous testing

63 of 78

64 of 78

How k6 fits into the Grafana Labs vision

65 of 78

The 4 golden signals

  • Network quality
  • Geolocation
  • Special event
  • Cyber attack
  • Bug (500)
  • Security/Auth
  • Bad planning
  • Infra issues

66 of 78

Testing needs observability

  • Network quality
  • Geolocation
  • Special event
  • Cyber attack
  • Bug (500)
  • Security/Auth
  • Bad planning
  • Infra issues

67 of 78

Testing needs observability

68 of 78

Observability needs testing

  • Network quality
  • Geolocation
  • Special event
  • Cyber attack
  • Bug (500)
  • Security/Auth
  • Bad planning
  • Infra issues

69 of 78

Observability needs testing

70 of 78

Pre-production

Production

Virtual User traffic

Real User traffic

Virtual User traffic

Proactively improve reliability

System in

Pre-prod

System in

production

Grafana IRM

Grafana O11y

71 of 78

72 of 78

73 of 78

Performance testing automation

74 of 78

Continuous performance testing

(1) Start simple. Iterate.

Dev/QA

Pre-release

Staging

Production

Scenario1: Smoke test

- verify with 1 iteration

- commit/branch changes

Scenario1: Average & Stress tests

- 3 times per day during QA period

- Regressions & SLOs

Scenario1

- 50% Average Once Nightly

- Smoke synthetic

Scenario1: Average

- Twice per week (baseline)

75 of 78

Continuous performance testing

CI/CD pitfalls

1. Continuous == Consistently and Frequently

2. Assume Thresholds / Quality gates will fail

76 of 78

Explore further - more features and examples!

grafana/

k6-oss-workshop

👩‍💻👨‍💻

grafana/

quickpizza

🍕🍕

77 of 78

Get involved

78 of 78

Thank you!