1 of 76

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 76

Introduction to k6

Your Name

Your Role at Your Company

3 of 76

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 76

What is load testing?

5 of 76

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

6 of 76

Load

Testing

✅ ❌

7 of 76

Load

Testing

Accept Errors: 9s of Reliability

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

8 of 76

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

9 of 76

What is load testing?

10 of 76

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

Scalability/Elasticity 📈

Resilience 💥

Availability 🟢

Reliability ✔️

Latency 🏎️

11 of 76

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

12 of 76

Common types of load tests

Breakpoint test

Spike test

Soak test

Average and peak test

13 of 76

Common types of load tests

Test Load

Test Duration

Smoke tests

Average load tests

Stress tests

Spike tests

Soak tests

Breakpoint tests

14 of 76

Why do load testing?

15 of 76

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 76

Why do load testing today?

UX

17 of 76

Why load testing today?

Distributed systems

18 of 76

Why load testing today?

SLOs - Reliability

Be proactive

19 of 76

Why load testing today?

Fragility

Embrace and Prevent Failures

20 of 76

Modern testing

Why k6?

21 of 76

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 76

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 76

Iterative:

Start simple

Modern testing. Why k6?

24 of 76

Team Effort

Modern testing. Why k6?

25 of 76

Modern testing. Distributed systems

End-to-end

Integration

Component

Browser / HTTP / WS

HTTP / gRPC / SQS

26 of 76

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 76

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 76

Start Simple and Test Frequently.

Fail Early.

Make Reliability a Team effort.

29 of 76

What is k6?

Free and open source tool

Paid performance testing platform

30 of 76

Open source

Same k6 test script for multiple execution modes

👉

31 of 76

Test as Code - Programmable

32 of 76

Test as Code - Programmable

33 of 76

Test as Code - Programmable

34 of 76

Limitations with NodeJS and browser libraries

40K VUs in one load generator

JAVASCRIPT RUNTIME

GOJA

GOLANG

*.js / *.ts

Performant

35 of 76

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 76

k6 Concepts

37 of 76

CLI flags

ENV variables

Script options

Default

Config file

Order of preference

Scenarios: Options

38 of 76

VU

Iterations

Scenario

VU

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

VU

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

VU

VU

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

VU

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

Duration

39 of 76

Built-in Metrics

Custom Metrics

new Trend(‘metric_name’);

new Rate(‘metric_name’);

new Counter(‘metric_name’);

new Gauge(‘metric_name’);

40 of 76

Checks

Thresholds

Like Unit testing, for Performance

41 of 76

Multiple Scenarios

Constant Arrival Rate

Ramping Arrival Rate

Per VU iterations

Ramping VUs

Shared iterations

Constant VUs

42 of 76

Session recording

👩‍💻

🌐

HAR file

HAR to k6 Converter

Response Correlation

Variable Parameterization

VU Data

Parameterization

43 of 76

K6 Studio

👩‍💻

🌐

Response Correlation

Variable Parameterization

VU Data

Parameterization

44 of 76

Open API Converter

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

$ k6 run petstore-test.ts

45 of 76

Test data

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

Faker Generate realistic data at runtime

46 of 76

Much more in

k6 docs

📚

47 of 76

Extensible (Full-stack / Hybrid testing)

48 of 76

Mimic Playwright API

Webvital metrics

k6 Browser 📚

49 of 76

Infrastructure testing / benchmarking

xk6-amqp

xk6-kafka

xk6-amqp

xk6-ethereum

xk6-celery

k6 extension JS API

k6 extension (GO)

xk6-sql

….

50 of 76

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.

👤

51 of 76

Full-stack / hybrid performance testing

End to end browser test

News API: average load test

52 of 76

Full-stack / hybrid performance testing

Account API: 100ms delay

End to end browser test

News API: average load test

UI

News

Account

🏋️

💣

👤

53 of 76

k6 Results

54 of 76

55 of 76

Terminal

Web dashboard

Visualization

Storage

k6 run script.js -o output-xyz

k6 run script.js

k6 Results

56 of 76

57 of 76

Healthy performance looks flat

58 of 76

Validate

SLOs and Quality gates

Test

result

Baseline

comparison

Correlate

with

system’s

data

Test

comparison

59 of 76

What’s Grafana Cloud k6?

60 of 76

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

61 of 76

62 of 76

How k6 fits into the Grafana Labs vision

63 of 76

The 4 golden signals

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

64 of 76

Testing needs observability

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

65 of 76

Testing needs observability

66 of 76

Observability needs testing

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

67 of 76

Observability needs testing

68 of 76

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

69 of 76

70 of 76

71 of 76

Performance testing automation

72 of 76

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)

73 of 76

Continuous performance testing

CI/CD pitfalls

1. Continuous == Consistently and Frequently

2. Assume Thresholds / Quality gates will fail

74 of 76

Explore further - more features and examples!

grafana/

k6-oss-workshop

👩‍💻👨‍💻

grafana/

quickpizza

🍕🍕

75 of 76

Get involved

76 of 76

Thank you!