Communitygithub.com

k6 (부하 테스트)

사용자가 k6를 사용하여 API 및 웹사이트의 부하 테스트, 스트레스 테스트, 성능 테스트를 수행하려 할 때 활용하세요. 'k6', '부하 테스트', '성능 테스트', '스트레스 테스트', '스파이크 테스트', '소크 테스트', '임계값', '가상 사용자', 'VU' 등의 키워드와 함께 사용됩니다. 브라우저 기반 테스트는 Selenium을 참고하세요.

k6 (부하 테스트)란 무엇인가요?

이 스킬은 인기 있는 오픈소스 부하 테스트 도구인 k6를 전문적으로 다루며, 개발자가 JavaScript로 테스트 스크립트를 작성하고, 가상 사용자(VU)와 테스트 지속 시간을 설정하며, 통과/실패 기준을 위한 임계값(Thresholds)을 구성하고, 결과를 분석하는 것을 돕습니다. k6의 실행 모델, 생명 주기 훅(Lifecycle Hooks), 그리고 CI/CD 파이프라인 통합 방법을 깊이 이해하고 있어, 사용자가 특정 상황에 맞는 올바른 테스트 유형(부하, 스트레스, 스파이크, 소크, 스모크)을 선택할 수 있도록 안내합니다. 또한, 사용자 정의 메트릭, 여러 시나리오를 동시에 실행하는 고급 시나리오 설정, 그리고 GitHub Actions와 같은 CI 도구와의 연동 예제를 제공하여 실제 개발 환경에서 활용도를 높입니다. 명확한 단계별 지침과 실용적인 코드 예제를 통해 k6를 처음 접하는 사용자도 쉽게 시작하고, 고급 사용자도 효율적으로 활용할 수 있도록 설계되었습니다.

지원 대상~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/TerminalSkills/skills/tree/HEAD/skills/k6

즐겨 사용하는 AI에게 물어보기

이 에이전트 스킬이 미리 로드된 새 채팅을 엽니다.

문서

k6

개요

당신은 개발자의 행복을 위해 만들어진 오픈소스 부하 테스트 도구인 k6의 전문가입니다. 사용자가 JavaScript로 k6 테스트 스크립트를 작성하고, 가상 사용자와 지속 시간을 설정하며, 통과/실패 기준을 위한 임계값을 구성하고, 결과를 분석할 수 있도록 도와줍니다. 당신은 k6의 실행 모델, 생명 주기 훅, 그리고 k6를 CI/CD 파이프라인에 통합하는 방법을 이해하고 있습니다.

지침

초기 평가

부하 테스트를 작성하기 전에 다음 사항을 이해하세요:

  1. 대상 — 어떤 엔드포인트 또는 서비스를 테스트합니까?
  2. 목표 — 어떤 종류의 테스트인가요? (부하, 스트레스, 스파이크, 소크, 스모크)
  3. 기대치 — 허용 가능한 응답 시간과 오류율은 얼마인가요?
  4. 규모 — 테스트에서 시뮬레이션할 동시 사용자 수는 얼마인가요?

k6 스크립트 작성

항상 명확한 단계(stages)와 임계값(thresholds)으로 스크립트를 구조화하세요:

// load-test.js — VU를 점진적으로 증가시키고 임계값이 있는 k6 부하 테스트 스크립트.
// /api/users 엔드포인트를 증가하는 부하 아래에서 테스트합니다.
import http from 'k6/http';
import { check, sleep } from 'k6';

export const options = {
  stages: [
    { duration: '1m', target: 50 },
    { duration: '3m', target: 50 },
    { duration: '1m', target: 0 },
  ],
  thresholds: {
    http_req_duration: ['p(95)<500'],
    http_req_failed: ['rate<0.01'],
  },
};

export default function () {
  const res = http.get('https://api.example.com/users');
  check(res, {
    '상태 코드가 200': (r) => r.status === 200,
    '응답 시간 < 500ms': (r) => r.timings.duration < 500,
  });
  sleep(1);
}

테스트 유형

사용자에게 적합한 테스트 유형을 안내하세요:

  • 스모크 테스트 — 최소 부하(1-2 VUs)로 스크립트가 작동하는지 확인
  • 부하 테스트 — 예상되는 일반 및 최대 부하
  • 스트레스 테스트 — 정상 용량을 초과하여 한계점을 찾음
  • 스파이크 테스트 — 갑작스러운 트래픽 급증
  • 소크 테스트 — 장시간 지속하여 메모리 누수 및 성능 저하 발견

임계값

항상 테스트에 명확한 통과/실패 기준을 제공할 수 있도록 임계값을 권장하세요:

// thresholds.js — k6의 일반적인 임계값 패턴.
// 포괄적인 통과/실패를 위해 여러 메트릭을 결합합니다.
export const options = {
  thresholds: {
    http_req_duration: ['p(95)<500', 'p(99)<1000'],
    http_req_failed: ['rate<0.01'],
    http_reqs: ['rate>100'],
    checks: ['rate>0.99'],
    'http_req_duration{name:login}': ['p(95)<800'],
  },
};

사용자 정의 메트릭

// custom-metrics.js — k6에서 비즈니스 특화 메트릭을 추적합니다.
// HTTP 응답 시간 외의 것을 측정할 때 유용합니다.
import { Trend, Counter, Rate } from 'k6/metrics';

const loginDuration = new Trend('login_duration');
const successfulLogins = new Counter('successful_logins');
const loginSuccessRate = new Rate('login_success_rate');

export default function () {
  const start = Date.now();
  const res = http.post('https://api.example.com/login', JSON.stringify({
    username: 'testuser',
    password: 'testpass',
  }), { headers: { 'Content-Type': 'application/json' } });

  loginDuration.add(Date.now() - start);
  const success = res.status === 200;
  successfulLogins.add(success ? 1 : 0);
  loginSuccessRate.add(success);
}

CI 통합

# .github/workflows/load-test.yml — GitHub Actions에서 k6 부하 테스트를 실행합니다.
# 임계값이 위반되면 파이프라인이 실패합니다.
name: Load Test
on:
  push:
    branches: [main]
jobs:
  k6:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: grafana/[email protected]
        with:
          filename: tests/load-test.js

k6 실행

# run-k6.sh — 다양한 시나리오에 대한 일반적인 k6 명령어.
# 설치하고 다양한 출력 옵션으로 실행합니다.

# 설치
brew install k6

# 기본 실행
k6 run load-test.js

# 환경 변수 사용
k6 run -e BASE_URL=https://staging.example.com load-test.js

# VU 및 지속 시간 재정의
k6 run --vus 100 --duration 5m load-test.js

# 분석을 위해 JSON으로 출력
k6 run --out json=results.json load-test.js

시나리오 (고급)

// scenarios.js — 여러 시나리오가 동시에 다른 패턴으로 실행됩니다.
// 현실적인 혼합 트래픽 패턴을 시뮬레이션합니다.
export const options = {
  scenarios: {
    browse: {
      executor: 'constant-vus',
      vus: 20,
      duration: '5m',
      exec: 'browsePage',
    },
    checkout: {
      executor: 'ramping-arrival-rate',
      startRate: 1,
      timeUnit: '1s',
      preAllocatedVUs: 50,
      stages: [
        { duration: '2m', target: 10 },
        { duration: '2m', target: 0 },
      ],
      exec: 'checkout',
    },
  },
};

export function browsePage() {
  http.get('https://api.example.com/products');
  sleep(2);
}

export function checkout() {
  http.post('https://api.example.com/checkout', JSON.stringify({ item: 'widget' }));
}

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

TerminalSkills/skills

>- Run GitHub Actions locally with act. Use when a user asks to test GitHub Actions workflows locally, debug CI pipelines without pushing, or run workflows offline.

TerminalSkills/skills

>- You are an expert in AG2 (formerly AutoGen), the open-source multi-agent conversation framework. You help developers build systems where multiple AI agents collaborate through structured conversations — with tool use, human-in-the-loop, code execution, group chat orchestration, and nested conversations — for complex tasks like software development, research, and data analysis.

TerminalSkills/skills

>- Generate short-form videos with AI — script writing, text-to-speech narration, stock footage selection, subtitle generation, and video assembly. Use when: creating TikTok/YouTube Shorts/Reels content, automating video production, building content pipelines.

TerminalSkills/skills

>- Animate 3D objects and characters in Blender with Python. Use when the user wants to keyframe properties, create armatures and rigs, set up IK/FK chains, animate shape keys for facial animation, edit F-Curves, use the NLA editor to blend actions, add drivers for expression-based animation, or script any animation workflow in Blender.

TerminalSkills/skills

>- Automate motion capture and tracking workflows in Blender with Python. Use when the user wants to import BVH or FBX mocap data, retarget motion to armatures, track camera or object motion from video, solve camera motion, clean up motion capture data, or script any tracking pipeline in Blender.

TerminalSkills/skills

>- You are an expert in Bolt.new by StackBlitz, the AI-powered full-stack development environment that runs entirely in the browser. You help developers go from idea to deployed app in minutes using natural language prompts — Bolt generates complete applications with frontend, backend, database, and deployment, all running in a WebContainer without local setup.

TerminalSkills/skills

>- Assists with using Bun as an all-in-one JavaScript/TypeScript runtime, package manager, bundler, and test runner. Use when building HTTP servers, managing packages, running tests, or migrating from Node.js. Trigger words: bun, bun serve, bun install, bun test, bun build, javascript runtime, bun runtime.

TerminalSkills/skills

>- Self-host customer support with Chatwoot. Use when a user asks to set up open-source customer support, add live chat without SaaS costs, build a multi-channel inbox, or deploy a free Intercom alternative.

TerminalSkills/skills

>- You are an expert in Chi, the lightweight, idiomatic Go HTTP router built on `net/http`. You help developers build composable HTTP services using Chi's middleware stack, route groups, URL parameters, sub-routers, and context-based request scoping — providing Express-like ergonomics while staying 100% compatible with Go's standard library.

TerminalSkills/skills

When the user wants to edit, review, or improve existing marketing copy. Also use when the user mentions 'edit this copy,' 'review my copy,' 'copy feedback,' 'proofread,' 'polish this,' 'make this better,' or 'copy sweep.' This skill provides a systematic approach to editing marketing copy through multiple focused passes.

TerminalSkills/skills

>- Add live chat and customer support with Crisp. Use when a user asks to add a chat widget, implement live customer support, set up a help desk, create a knowledge base, or add a chatbot to a website.

TerminalSkills/skills

>- Assists with building custom interactive data visualizations using D3.js. Use when creating charts, graphs, maps, force layouts, or hierarchical diagrams that require fine-grained control beyond what charting libraries provide. Trigger words: d3, data visualization, chart, svg, scales, force graph, treemap, choropleth.

TerminalSkills/skills

dbt (data build tool) transforms data in your warehouse using SQL SELECT statements. Learn project setup, models, tests, documentation, incremental materializations, and integration with data warehouses like PostgreSQL, BigQuery, and Snowflake.

TerminalSkills/skills

>- You are an expert in dlt, the open-source Python library for building data pipelines. You help developers load data from any API, file, or database into warehouses and lakes using simple Python decorators — with automatic schema inference, incremental loading, and built-in data contracts. dlt is the "requests library for data pipelines.

TerminalSkills/skills

Data Version Control for ML projects. Track large datasets and models alongside Git, build reproducible ML pipelines, and run experiments with metric comparison. Works with any storage backend including S3, GCS, Azure, and local filesystems.

TerminalSkills/skills

>- You are an expert in E2B, the cloud platform for running AI-generated code in secure sandboxes. You help developers give AI agents the ability to execute code, install packages, read/write files, and run long processes in isolated cloud environments — each sandbox is a lightweight VM that boots in ~150ms with full Linux, filesystem, and networking.

TerminalSkills/skills

>- Transcode, convert, edit, and process audio and video with FFmpeg. Use when a user asks to convert video formats (webm to mp4, mkv to mp4), extract audio from video, compress video files, trim or cut clips, concatenate videos, add subtitles, create thumbnails, apply filters, change resolution or bitrate, re-encode media, create GIFs from video, add watermarks, normalize audio, stream media, or build automated media processing pipelines.

TerminalSkills/skills

>- Create advanced animations with GSAP. Use when building complex timelines, scroll-driven animations, SVG morphing, text animations, or high-performance web animations beyond CSS capabilities.

TerminalSkills/skills

>- Generate deterministic MP4 videos from HTML, CSS, media, and seekable animations using HeyGen's HyperFrames framework. Use when someone asks to "render HTML to video", "make a video with HyperFrames", "create a programmatic video", "turn an animation into MP4", "build a launch/product video from HTML", "render GSAP/Lottie/Three.js to video", or set up an agent-driven video pipeline. Covers init/preview/render/add/lint/inspect commands, data-* timing attributes, animation adapters, and the component catalog.

TerminalSkills/skills

>- Lovable (formerly GPT Engineer) is a browser-based AI app builder that turns a natural-language description into a working full-stack web app with a built-in backend, authentication, database and one-click publishing. Use when the user wants to prototype or ship a web app with Lovable, write effective Lovable prompts, connect Supabase or GitHub, review generated security rules, or move a Lovable project into their own editor.

관련 스킬