import http from 'k6/http';
import { sleep } from 'k6';
export const options = {
stages: [
{ duration: '30s', target: 10 }, // Warm up
{ duration: '10s', target: 200 }, // SPIKE!
{ duration: '1m', target: 200 }, // Hold spike
{ duration: '10s', target: 10 }, // Recovery
{ duration: '30s', target: 10 }, // Verify recovery
{ duration: '10s', target: 0 }, // Ramp down
],
};
export default function () {
http.get('https://myapp.com/api/products');
sleep(1);
}Stress testing gradually increases load to find the breaking point. Spike testing instantly jumps to high load to test how your system handles sudden surges and recovers afterward.
k6 can ramp from 0 to your VU limit in seconds. The 10-second stage in the example above jumps from 10 to 200 VUs almost instantly — perfect for simulating viral traffic.
Stress test your website with up to 200 virtual users for free. Find performance bottlenecks and ensure your site handles traffic spikes.
Run extended soak tests to find memory leaks, connection pool exhaustion, and performance degradation over time.
Use load testing for infrastructure capacity planning. Determine how many users your servers can handle and when to scale.