Skip to main content
Scenarios provide fine-grained control over how k6 executes your test workload. They let you model diverse traffic patterns and complex user behaviors in a single test.

What are scenarios?

Scenarios configure how VUs (virtual users) and iterations are scheduled during test execution. Each scenario can:
  • Execute a different JavaScript function
  • Use a different executor to control workload patterns
  • Run in parallel or sequence with other scenarios
  • Have independent environment variables and tags

Why use scenarios?

Scenarios provide several benefits over simple VU/duration configuration:

Realistic traffic patterns

Model different user behaviors with arrival rates, iterations, or ramping patterns.

Multiple workloads

Run different test functions in parallel or sequence within one test.

Better organization

Separate different test phases or user types into distinct scenarios.

Granular analysis

Tag and analyze each scenario independently with scenario-specific metrics.

Basic scenario configuration

Define scenarios in the options.scenarios object:
Each scenario requires:
  • A unique name (my_scenario)
  • An executor property specifying the workload pattern
  • Executor-specific configuration (like vus and duration)

Scenario executors

Executors determine how k6 schedules VUs and iterations. Choose the executor that best matches your workload:

By iterations

A fixed number of iterations shared between VUs.
Use when: You need exactly 100 iterations, distributed among VUs.

By VUs

A constant number of VUs for a duration.
Use when: You want steady load with 50 VUs for 1 minute.

By arrival rate

Fixed iteration rate (open model).
Use when: You need exactly 100 requests per second, regardless of response time.

Scenario options

All scenarios support these common options:

Multiple scenarios

Run multiple scenarios in parallel:
This runs a load test for 5 minutes, then immediately starts a stress test.

Scenario-specific tags and environment

Tag metrics by scenario:

Complete example

Here’s a realistic scenario combining multiple patterns:

Scenario execution output

When running scenarios, k6 displays scenario information:
Results are shown both overall and per-scenario:

Best practices

Choose the right executor

Use VU-based executors for closed models, arrival-rate executors for open models.

Use meaningful names

Name scenarios descriptively: “warmup”, “load_test”, “spike” not “scenario1”.

Tag for analysis

Add scenario-specific tags to enable granular threshold and analysis.

Sequence with startTime

Use startTime to create sequential test phases within one test run.

Next steps

Executors Reference

Detailed documentation for each executor type with advanced options