Skip to content
  • English Deutsch

benjamin-abt.com

Performance is a feature | Cloud - AI - Azure - .NET - Sustainability

  • Home
  • Blog
  • Portfolio
    • Overview
    • Workshops & Training
    • Publications
  • Contact
  • Home
  • Blog

Web performance tests with k6

benjamin-abt.com
January 26, 2023 3 min read BEN ABT

This article was written in 2023. Versions, tools and recommendations may have changed since then. Newer posts are collected under Blog.

Performance testing is a crucial step in ensuring that your website can handle high levels of traffic and provide a smooth user experience. One tool that can help you perform performance tests on your website is k6. In this blog post, we’ll go over how to use k6 to test the performance of your website.

Install

You can install k6 very easily with npm or use the manual installer on https://k6.io/

Shell
npm install -g k6

Run

Once k6 is installed, you can use it to run performance tests on your website. One of the simplest ways to do this is to create a script that defines the test scenario and then run the script using k6.

JavaScript
1import { check } from 'k6';
2
3import http from 'k6/http';
4export default function () {
5  let res = http.get(`https://google.com`);
6  check(res, {
7    'is status 200': (r) => r.status === 200,
8  });
9}

This script uses k6’s built-in http module to make a GET request to the specified URL (in this case, https://google.com). It also uses the check function to check that the response has a status of 200, indicating that the request was successful.

To run the script save it as test.js, you can use the following command:

Shell
k6 run test.js --vus 20 --duration 30s

The result will be like

Shell
 1    checks.....................: 100.00% ✓ 2936 ✗ 0
 2    data_received..............: 70 MB   2.3 MB/s
 3    data_sent..................: 429 kB  14 kB/s
 4    http_req_blocked...........: avg=839.05µs min=100ns    med=200ns    max=130.71ms p(90)=300ns    p(95)=300ns
 5    http_req_connecting........: avg=298.5µs  min=0s       med=0s       max=58.12ms  p(90)=0s       p(95)=0s
 6    http_req_duration..........: avg=204.06ms min=111.92ms med=192.73ms max=794.46ms p(90)=238.85ms p(95)=267.37ms
 7    http_req_receiving.........: avg=2.74ms   min=42.6µs   med=2.56ms   max=16.55ms  p(90)=4.47ms   p(95)=5.9ms
 8    http_req_sending...........: avg=26.04µs  min=11.7µs   med=25µs     max=151.4µs  p(90)=28.9µs   p(95)=31.92µs
 9    http_req_tls_handshaking...: avg=368.08µs min=0s       med=0s       max=72.96ms  p(90)=0s       p(95)=0s
10    http_req_waiting...........: avg=201.29ms min=111.85ms med=189.9ms  max=791.47ms p(90)=235.46ms p(95)=264.09ms
11    http_reqs..................: 2936    97.212535/s
12    iteration_duration.........: avg=205.01ms min=112.02ms med=192.84ms max=794.55ms p(90)=239.62ms p(95)=269.16ms
13    iterations.................: 2936    97.212535/s
14    vus........................: 20      min=20 max=20
15    vus_max....................: 20      min=20 max=20

This is just a simple example of how to use k6 to performance test a website. Keep in mind that you can also use k6 to test other types of web services and can combine multiple APIs to test application performance as well. Additionally, k6 allows to test with different scenarios such as load testing, spike testing and soak testing.

In summary, k6 is a powerful and flexible tool for performance testing your website. With just a little bit of setup, you can use k6 to quickly and easily test the performance of your website and ensure that it can handle high levels of traffic.


BEN ABT

BEN ABT

Ben is Chief Engineering Officer and Principal Software Engineer at Medialesson.de, with a strong focus on .NET and Microsoft Azure. In his professional role, he designs and builds highly scalable platforms for hybrid and cloud-based scenarios. He also advises companies and C-levels on migrating to the sovereign cloud.

He runs myCSharp.de, the largest and most active German-speaking C# community forum, actively contributes to both his own and external open-source projects and regularly shares his knowledge through his blog, at community events, conferences and as a writer for technical magazines.

Let's Work Together

Looking for an experienced Platform Architect or Engineer for your next project? Whether it's cloud migration, platform modernization or building new solutions from scratch - I'm here to help you succeed.

New Platforms

Modernization

Training & Consulting

Contact Me
X Facebook LinkedIn WhatsApp
Back Next Blog Post

Open for work!

Contact Me
BEN ABT BEN ABT Software Engineer · Microsoft MVP Passionate about .NET, Azure, performance optimization and sustainable software engineering.

Medialesson GmbH Logo

Microsoft MVP Logo

Recent posts

View all
Stop Using nginx as Your Default Static File Server in Docker

Stop Using nginx as Your Default Static File Server in …

Oct 24, 2026
Containerizing .NET in 2026 Without a Dockerfile

Containerizing .NET in 2026 Without a Dockerfile

Oct 20, 2026
Problem Details in ASP.NET Core and .NET 11

Problem Details in ASP.NET Core and .NET 11

Oct 5, 2026
Resilience in .NET with Microsoft.Extensions.Resilience

Resilience in .NET with Microsoft.Extensions.Resilience

Sep 21, 2026
What Matters in ASP.NET Core 11

What Matters in ASP.NET Core 11

Sep 14, 2026

Tags

.NET (192) Csharp (96) ASP.NET Core (48) Azure (41) DevOps (17) Docker (14) Microsoft (14) EF Core (11) Microsoft MVP (11) AI (10) GitHub (10) GitHub Copilot (10) ASP.NET (9) Security (9) Synology (9) Architecture (8) Raspberry (8) Azure Functions (7) Cloudflare (7) Bicep (6)
benjamin-abt.com

About BEN

Benjamin Abt is a Software Engineer, Platform Architect and Microsoft MVP specializing in .NET, Azure, cloud architecture, performance optimization and sustainable software development.

Connect

  • Follow me on GitHub
  • Follow me on LinkedIn
  • Follow me on Mastodon
  • Microsoft MVP profile
  • Follow SchwabenCode on GitHub
  • Follow me on X

Quick Links

  • Portfolio
  • Blog
  • Workshops & Training
  • Publications
  • Get in Touch
  • Sitemap
Open for Work

© Copyright Benjamin Abt & SchwabenCode | 2011 - 2026

Content licensed under CC BY 4.0 unless otherwise noted.

  • Impressum
  • Privacy
  • Contact