K6 | Sheetly Cheat Sheet

K6 | Sheetly — a quick reference covering core concepts, practical examples, and best practices.

Last Updated: November 21, 2025

K6

Modern load testing tool

Core Features

Item Description
JavaScript DSL Write tests in JS
CLI Tool Run from command line
Metrics Built-in performance metrics
Thresholds Pass/fail criteria
Checks Inline assertions
Cloud Optional cloud execution

Basic Load Test

import http from 'k6/http';
import { check, sleep } from 'k6';

export const options = {
  vus: 10,          // Virtual users
  duration: '30s',  // Test duration
  thresholds: {
    http_req_duration: ['p(95)<500'], // 95% under 500ms
    http_req_failed: ['rate<0.01'],   // < 1% failure
  },
};

export default function () {
  const res = http.get('https://api.example.com/users');
  
  check(res, {
    'status is 200': (r) => r.status === 200,
    'response time < 500ms': (r) => r.timings.duration < 500,
  });
  
  sleep(1);
}

Load Profiles

export const options = {
  stages: [
    { duration: '2m', target: 100 },  // Ramp up
    { duration: '5m', target: 100 },  // Stay at 100
    { duration: '2m', target: 200 },  // Ramp to 200
    { duration: '5m', target: 200 },  // Stay at 200
    { duration: '2m', target: 0 },    // Ramp down
  ],
};

Best Practices

  • Set realistic think time with sleep()
  • Use checks for inline assertions
  • Set thresholds for pass/fail criteria
  • Start small and gradually increase load

💡 Pro Tips

Quick Reference

K6 is built for developer productivity

← Back to Data Science & ML | Browse all categories | View all cheat sheets