- Platform: Udemy
- Instructor: Anuradha Agarwal
- Duration: 12:32:25
- Rating: 3.5/5
- Release Date: May 2023
- Course Link: https://www.udemy.com/course/k6-automate-performance-load-testing-of-api-microservices
This document summarizes the key points from the course. I highly recommend watching the full course if you have the opportunity.
- I summarize key points from useful courses to learn and review quickly.
- Simply click on
Ask AIlinks to dive into any topic you want.
Teach Me: 5 Years Old | Beginner | Intermediate | Advanced | (reset auto redirect)
Learn Differently: Analogy | Storytelling | Cheatsheet | Mindmap | Flashcards | Practical Projects | Code Examples | Common Mistakes
Check Understanding: Generate Quiz | Interview Me | Refactor Challenge | Assessment Rubric | Next Steps
- Summary: This section covers the basics of K6 as an open-source load testing tool for APIs and microservices. It highlights features like being free, developer-friendly, and its use for performance monitoring, automation in CI/CD, and cloud execution from multiple locations.
- Example: For instance, K6 can simulate thousands of concurrent users hitting an API like Google.com to measure response times and failures, showing metrics such as request rate and virtual users in a simple JavaScript script.
- Link for More Details: Ask AI: Introduction to K6
- Summary: Explains the difference between running K6 locally on your machine for free and using K6 Cloud for infrastructure-free testing from various geographic locations, avoiding the need for personal servers or laptops.
- Example: Running a test locally might use your laptop to generate load, while K6 Cloud allows hitting APIs from regions like USA, Mumbai, or Tokyo simultaneously without managing EC2 instances.
- Link for More Details: Ask AI: Local vs Cloud Deployment
- Summary: Guides through installing K6 on Windows or Linux, creating a Git project, cloning it, and setting up a Visual Studio Code environment for writing tests.
- Example: After downloading the MSI installer for Windows, create a blank Git project named "k6-performance", clone it locally, and open it in VS Code to start scripting.
- Link for More Details: Ask AI: Installation and Project Setup
- Summary: Discusses API testing concepts, workflows like ordering on sites such as Flipkart, collecting API details from developers, and defining test metrics like response time and failure rates.
- Example: For a Flipkart order workflow, capture APIs for visiting the site, selecting products, adding to cart, and checkout, then test with thousands of users to ensure no failures and quick responses.
- Link for More Details: Ask AI: Understanding API Performance Testing
- Summary: Teaches how to write simple JavaScript scripts to hit APIs, import modules, and execute tests using the K6 run command.
- Example: Import HTTP, define a default function to get Google.com, and run the script to see metrics like response time for a single user.
- Link for More Details: Ask AI: Writing Basic Load Test Scripts
- Summary: Covers specifying virtual users (VUs) and test duration via command line or options in the script for simulating concurrent loads.
- Example: Set options { vus: 10, duration: '10s' } in the script to run 10 users for 10 seconds without command-line arguments.
- Link for More Details: Ask AI: Configuring Virtual Users and Duration
- Summary: Introduces stages in options to gradually increase or decrease VUs over time for realistic load simulation.
- Example: Use stages: [{ duration: '10s', target: 5 }, { duration: '20s', target: 3 }] to ramp up to 5 users, then down to 3.
- Link for More Details: Ask AI: Ramp Up and Ramp Down User Load
- Summary: Explains adding checks to verify responses without halting execution, like status codes, to determine pass/fail.
- Example: Import check, capture response, and check if response.status === 200, logging green for pass or red for fail.
- Link for More Details: Ask AI: Using Checks and Assertions
- Summary: Demonstrates creating a GitLab pipeline with .gitlab-ci.yml to run K6 tests automatically on code pushes, including environment variables.
- Example: Define stages and jobs in YML to run K6 scripts, fix paths, and view successful job executions in the pipeline dashboard.
- Link for More Details: Ask AI: Setting Up CI/CD Pipeline with GitLab
- Summary: Advises on choosing machines with sufficient RAM/CPU, preferring lightweight OS like Linux over Windows for accurate results.
- Example: Start with an EC2 instance of 1 vCPU and 2GB RAM for 100 VUs, monitor CPU/memory on cloud console to avoid hangs or errors.
- Link for More Details: Ask AI: Selecting the Right Runner for Testing
- Summary: Discusses how third-party libraries and large JS files add overhead, affecting response times and resources; advises minimalism and realistic loads.
- Example: Avoiding excess NPM packages prevents millisecond delays that scale to seconds under high load, ensuring accurate metrics.
- Link for More Details: Ask AI: Managing Performance Overhead
- Summary: Covers using console.log and --http-debug=full flag to generate logs for troubleshooting issues in scripts.
- Example: Add console.log(response.body) to print API responses, or use the debug flag to see full headers and bodies for error analysis.
- Link for More Details: Ask AI: Debugging K6 Scripts
- Summary: Explains running multiple scripts together, limitations in older versions, and using newer features for parallel execution without overhead.
- Example: Import and call functions from test1.js and test2.js in a main script, but note configurations apply from the main file only.
- Link for More Details: Ask AI: Executing Multiple Test Cases
- Summary: Introduces scenarios for running multiple tests independently with separate configurations, executors like constant or ramping VUs.
- Example: Define scenarios with constant-vus executor for fixed users, or ramping-vus for staging, each calling different functions with env vars.
- Link for More Details: Ask AI: Using Scenarios in K6
- Summary: Teaches recording browser sessions to HAR files, converting them to K6 scripts, and fixing issues for load testing.
- Example: Use Chrome dev tools to record navigation on a site, save as HAR, convert with har-to-k6 tool, then edit to remove unsupported protocols like WSS.
- Link for More Details: Ask AI: Recording and Auto-Generating Scripts with HAR
For the complete experience, check out the full course on Udemy: K6- Automate Performance & Load Testing of API & Microservices
About the summarizer
I'm Ali Sol, a Backend Developer. Learn more:
- Website: alisol.ir
- LinkedIn: linkedin.com/in/alisolphp