
Explore performance testing with k6 for beginners, learn to install, run your first test, write JavaScript assertions, set thresholds, and integrate tests with CI/CD and Grafana.
Begin your hands-on journey with K6, mastering its use through practical exercises, quizzes, and assignments. Access downloadable resources, troubleshooting guides, Q&A, and course announcements to enhance your learning experience.
install k6 on Windows, macOS, and Linux via the official installer or homebrew, then write and run your first test using k6 in Visual Studio Code.
Exercise caution with k6 for performance testing by using approved test environments, coordinating with your team, and avoiding production, while learning to map architecture and external API impacts.
Explore basic performance testing concepts with k6, including virtual users, requests, latency, throughput, and iterations, to understand how websites cope with concurrent traffic.
Configure K6 performance tests by setting virtual users and test duration, use sleep to simulate pauses, and interpret iterations versus requests.
Identify performance issues by focusing on http request duration and percentile metrics (p90, p95) in k6, and interpret results with SLOs rather than averages.
Clarify the differences between performance, load, stress, and spike tests and learn how to configure these tests in CS6, with guidance from the K6 documentation.
Explore why performance testing matters and use k6 to simulate concurrent users, spike and stress tests, identify bottlenecks, and ensure a smooth, efficient experience for all your users.
Explore how systems scale: compare vertical scaling (scaling up) and horizontal scaling (scaling out), and contrast monolithic apps with microservices for elastic cloud infrastructure.
Perform a smoke test to validate basic functionality of the application and the test script, using a single virtual user to establish baseline metrics and identify early issues.
Learn to perform smoke tests with k6 by scripting automated checks of start, contact, and news pages using one virtual user for 30 seconds, and analyze failed requests and metrics.
Conduct load testing with empirical data to establish a baseline of typical concurrent users. Design the test with ramp up, duration, and ramp down to reflect real user behavior.
Learn to perform load testing with k6 by configuring stages, ramping from one to 100 users, staying steady, and ramping down, in a pre-production environment.
Explore stress testing, how it extends load testing by applying above-normal loads to evaluate performance, degradation, ramp-down recovery, and acceptable limits under demanding conditions.
Learn how to conduct stress testing with k6 by duplicating a load test, gradually increasing virtual users (10%, 20%, 50%, 100%), after a successful load test, to simulate above-average conditions.
Test how the application behaves under sudden user spikes with spike testing, such as during product launches or TV commercials. Expect inexistent ramp up time and uneven load across components.
configure spike testing in k6 to simulate a sudden surge from zero to thousands of users with a steep ramp up and ramp down, and assess crash risk and recovery.
Determine maximum capacity with a breakpoint test that uses a single, long stage. Gradually increase load, monitor errors and response times, then stop and export results for elastic scaling analysis.
Configure a soak test in k6 by extending a load test to long durations, and detect issues that arise after sustained load, such as memory leaks and disk space growth.
Wrap up by explaining why tests are needed and how to configure them in k6. Begin with the basics and adapt stage-based load and stress tests to fit your needs.
Write k6 scripts from scratch, import http, and perform Http.get requests to websites or APIs, store responses, and inspect status codes and bodies with console logs.
Write assertions in k6 using the check function, importing check from k6 and passing response data with a checks object for clear, named assertions.
Learn to validate http responses in k6 by writing checks for status is 200 and body content, using the includes method, and combine multiple checks for robust performance testing.
Configure thresholds in k6 to automatically raise alarms on performance deviations, using p95 request duration under 100 ms and http error rate under 1%, with checks and service level objectives.
Explore metric types such as counters, gauges, rates, and trends in k6, and learn to craft thresholds for http requests using count, rate, value, and percentile aggregations.
Define and test thresholds for checks in k6, simulate a single failing request across iterations, and use the checks rate metric (0.98) to determine when an execution fails.
Create custom metrics in k6 by importing the metrics module and defining a counter. Initialize the metric outside the default function, increment with add, and set thresholds for reporting.
Create a custom k6 metric using a trend to track per-request timings from the response timings, populate it with the add method, and enforce 95th and 99th percentile thresholds.
learn to use K6 tags to drill into http request duration by status, simulate scenarios with mocks, set thresholds, and filter results with system tags to identify slow endpoints.
Tag k6 entities with custom tags to categorize requests, checks, and metrics, then filter thresholds and view tagged results in reports for page specific analysis.
Organize k6 load tests with groups to structure page and asset requests, create main and news page groups, and use subgroups with callback functions for clear, scalable test scenarios.
Define thresholds for a specific group based on the group duration metric with tag filtering to drill into main page and assets subgroups, revealing how the threshold is crossed.
See how k6 builds the group duration metric using mock delays (5s main, 1s per request, 2s assets) and a load matrix to estimate total page load time.
Revisit the http request duration metric and learn to filter out errors, measuring only successful responses (between 200 and 399) to prevent fast error pages from skewing metrics.
Explore the k6 test script lifecycle from init and setup to the default function and teardown, importing modules, using sleep, and passing setup data.
Learn how to abort a k6 performance test with a setup function by checking a status page, importing exec from k6/execution, and calling exec.abort with a message.
Explore the http protocol basics and learn to construct http requests with Rc6, including get, post, put, patch, and delete, plus authentication and practical api testing using postman.
Learn the fundamentals of web APIs as interfaces to data on remote servers, using examples like weather apps and tools like Postman to explore API interoperability.
Explore the fundamentals of HTTP and HTTPS, and learn how browser requests and server responses exchange data through methods, headers, and bodies, guided by API conventions.
Explore making a get request to a rest api using Postman and k6, access the public crocodiles endpoint, and interpret the json response with a status 200.
Learn how json transfers data between systems by structuring information as key-value pairs. Understand valid json versus invalid json, including quotes, braces, arrays, strings, numbers, and booleans.
Use the http debug flag in k6 to view request and response details, headers and status codes; reveal full bodies hidden by default with the equal sign.
Learn how to fetch crocodile data via rest endpoints in k6, check status codes, and parse json to access properties like name, ensuring accurate assertions on single-resource responses.
Demonstrates correlating requests by extracting a dynamic id from a list response and using it in subsequent requests, avoiding hardcoded ids and enabling reliable k6 performance tests.
Learn how to access response headers in k6 scripts by reading the headers object and retrieving specific values like allow and content-type, using bracket notation for headers with special characters.
Learn to send data with a post request, construct json bodies, set content-type headers, and validate responses in postman and k6.
Practice sending a JSON body containing a username and password to obtain a bearer JWT token, reference Postman steps, implement in k6, and print access token.
Learn to perform a POST request in k6 by sending a json body with username and password, adding headers, and extracting the access token from the response.
Refactor test scripts to remove hard coded data by introducing a credentials object and using json.stringify for the request body, ensuring login uses credentials.username and credentials.password.
Learn token-based authentication for private APIs, using bearer tokens or json web tokens, to securely access endpoints with k6 by including an authorization header.
Showcases authenticating with an access token, posting json payload to create a new crocodile with name, sex, and date of birth via a private api in Postman.
Reuse the same endpoint for get and post to create a crocodile with k6, sending a json body and proper headers (content-type and authorization) to return the new id.
Capture the new crocodile's ID from the creation response and retrieve only that crocodile using the required endpoint.
Retrieve a created crocodile via the crocodiles endpoint, extract the ID from the response, build a dynamic get request with backticks, and verify a 200 status and matching ID.
Verify http messages and watch 301 redirects that move resources. k6 handles redirects by adding extra requests and altering metrics; review logs and consistently align tests with real-world behavior.
Learn how to perform a put request in k6 to update an existing crocodile resource, preserving the ID, by sending a full JSON body and headers with a valid token.
Learn how patch updates only specific fields, compare patch to put in APIs, and implement patch in k6 using postman steps and token authentication for a 200 response.
Perform an http delete request to remove a crocodile via the endpoint, using a bearer token and no body; verify with a get request and a 204 no content response.
Learn how to use environment variables in k6 scripts to switch the base url across test, pre-production, and production environments, using dash e, __env, and template literals.
Demonstrate randomized think time in k6 by using sleep between 1 and 5 seconds for five virtual users, replacing hard coded pauses with a random int between minimum and maximum.
Learn to generate unique test data in k6 with the random string function to avoid credential collisions across multiple virtual users, importing and using an eight-character string.
Extract crocodile ids using map, then use k6 random item to pick a random id and avoid hard coding by requesting that crocodile, creating realistic, dynamic test data.
Learn how to read credentials from an external json file with a shared array in k6, register users, obtain auth tokens, and reuse existing users for authenticated requests.
Parse a csv file of usernames and passwords in k6 with a shared array, using a header to map columns, then iterate the data to drive requests.
Use K6 cloud to run tests, generate reports, and offload script execution from your machine, with distributed testing across global regions and real-time server monitoring.
Learn to create a Grafana cloud account, verify email, customize your URL and region, and explore k6 cloud benefits including a free trial and 500 virtual user hours.
Login to the k6 cloud via the CLI or API token, then run your script in the cloud and view performance metrics.
Run k6 locally and export the test execution report to the cloud using the CLI with the -O cloud option, then monitor results via cloud streaming.
replace the default grafana project by creating a new one, and link k6 executions to it using a cloud project ID. this setup streams results to grafana cloud.
Demonstrates cloud-based performance testing with k6 on the crocodile API, configuring project IDs and ramped virtual users, while inspecting real-time metrics and percentile latency data.
Learn how to interpret k6 cloud warnings about too many metrics and dynamic endpoints, and fix them by tagging urls to override the name and group requests, then verify thresholds.
Explore the k6 command-line interface and discover a range of capabilities for performance testing, gaining an overview of options you may use as needed.
Run k6 quickly by using command line flags to set virtual users, duration, and iterations, overriding configuration with the highest precedence, and avoiding code changes.
Configure k6 to bypass certificate verification for self-signed https, using the insecure skip verify flag to prevent request failures caused by unknown authority.
Export k6 test results to json to create a concise summary.json. Obtain a detailed full results json with tags and metrics for third-party integration.
Explore the official k6 documentation to learn how to configure common CLI options using environment variables, CLI flags, or a config, and apply them in your script.
Automate performance testing by integrating k six performance tests into CI/CD pipelines to assess the impact of every software change in real time.
Explore how k6 communicates with ci cd pipelines using exit codes: zero means success, non-zero signals errors, enabling job failures and alerts when thresholds are crossed.
Install and verify k6 on the Jenkins agent, then run tests via freestyle, scripted pipelines, or Docker-based pipelines using Grafana/k6.
Integrate Jenkins with the k6 CLI by cloning your repo, running k6 with script.js, and configuring freestyle, Jenkinsfile, and Docker-based pipelines to produce concise reports.
Learn to run k6 performance tests via the cloud from Jenkins, manage credentials securely with Jenkins credentials, and configure environment variables for project ID to avoid authentication errors.
Learn how to run k6 tests in GitLab CI using a Grafana for k6 image and a CI pipeline. Configure cloud and local executions with tokens and project IDs.
Preview topics left out as we near the end of the course to give you a taste of key concepts you should know.
Assess test execution reports to validate scenario accuracy, load, and checks in k6. Learn to evaluate requests per second, iterations, and response content to ensure a valid performance test.
Learn how to use the experimental k6 browser module to open a web app with chromium, run tests in headless or visible mode, and capture performance data and screenshots.
Explore continued learning with k6 through official documentation, office hours, and the YouTube channel, then engage the community forum and Q&A, and share your feedback with a course review.
Dive into the dynamic world of k6 performance testing, designed to transform beginners into proficient testers. This course emphasizes building confidence starting with the basics of JavaScript, the language that powers k6.
Here is a brief overview of the course contents:
Getting Started: Learn the ABCs of k6, including installation processes and how to set up your very first test. This foundational knowledge is akin to learning to ride a bike; once you've grasped the basics, advancing becomes substantially easier.
Introduction to Performance Testing: We shed light on the compelling world of performance testing, demystifying essential terms and unfolding the variety of tests executable using k6.
Advanced Techniques: Delve deeper into k6 intricacies such as validating responses, crafting assertions, and handling complex scenarios. Gain proficiency in using the K6 Command Line Interface (CLI) and explore the offerings of Grafana Cloud k6.
Integration with CI/CD: The course covers integrating k6 tests into renowned CI/CD servers like Jenkins, GitLab CI, and Circle CI. This segment prepares you to apply your k6 skills globally in real-world scenarios.
Why take this course?
Whether your application operates through HTTP, web service, or gRPC, k6 serves as a versatile tool, efficiently assessing performance. The course makes the learning process less demanding and more engaging for learners at all levels.
Are you ready to transform from a novice to a skilled tester? Join us on this insightful adventure into the world of k6 performance testing. Let’s embark on this learning journey together!
Legal Disclaimer
This course is an independent educational resource and is not endorsed by, affiliated with, or associated with Grafana Labs, k6, or any of their products or services. k6, Grafana, and related marks are trademarks of Raintank, Inc. d/b/a Grafana Labs. All product names, logos, and brands mentioned in this course are the property of their respective owners.
This course contains promotional materials.