Performance12 min read•Updated November 2026

How to Load Test a Web Application with k6 Using a VPS

Quick answer

Install k6 on a VPS that is separate from the server you are testing, write a JavaScript test that requests your key pages or API endpoints, and use stages to ramp virtual users up, hold and ramp down. Add thresholds such as http_req_duration: ['p(95)<500'] and http_req_failed: ['rate<0.01'] so the run passes or fails automatically. Run against staging, watch the target server's CPU, memory and database while the test runs, and increase load until a threshold breaks to find capacity.

Load testing answers questions that monitoring cannot: how many users can the site handle before it slows down, what breaks first, and did the last release make things worse? k6 is an open-source load testing tool from Grafana Labs that is scripted in JavaScript, runs from the command line and uses resources efficiently. A VPS makes a good load generator because it has a stable, fast connection and can sit close to your servers.

Before You Start: Test Safely

  • Only test systems you own or have permission to test. Load tests against other people's servers can look like an attack.
  • Prefer staging with production-like data and configuration (see our staging guide).
  • If you test production, do it at a quiet time, start small, tell your team and your hosting provider if they ask for notice, and be ready to stop.
  • Avoid side effects: do not place real orders or send real emails; use test accounts and sandbox payment keys.

Step 1: Install k6

On Debian or Ubuntu, add Grafana's package repository and install, following the current instructions in the k6 documentation, or run the official Docker image:

docker run --rm -i grafana/k6 run - <script.js

Check the install with k6 version.

Step 2: Write a Realistic Script

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

export const options = {
  stages: [
    { duration: '2m', target: 50 },   // ramp up to 50 virtual users
    { duration: '5m', target: 50 },   // hold
    { duration: '2m', target: 0 },    // ramp down
  ],
  thresholds: {
    http_req_duration: ['p(95)<500'],  // 95% of requests under 500 ms
    http_req_failed: ['rate<0.01'],    // less than 1% errors
  },
};

const BASE = __ENV.BASE_URL || 'https://staging.example.com';

export default function () {
  const home = http.get(`${BASE}/`);
  check(home, { 'home 200': (r) => r.status === 200 });
  sleep(Math.random() * 3 + 1);       // think time, 1-4 s

  const product = http.get(`${BASE}/products/sample-product`);
  check(product, { 'product 200': (r) => r.status === 200 });
  sleep(Math.random() * 3 + 1);
}

Model what users actually do: the pages they visit, in roughly the proportions they visit them, with pauses between actions. A test that hammers one URL with no think time measures something, but not your real capacity.

Step 3: Run It

BASE_URL=https://staging.example.com k6 run script.js
# or
k6 run -e BASE_URL=https://staging.example.com script.js

Run k6 inside tmux on the VPS so the test continues if your SSH connection drops.

Step 4: Read the Results

MetricWhat it tells you
http_req_duration (p90, p95, max)Response times; percentiles matter more than the average
http_req_failedShare of failed requests (network errors and, by default, 4xx/5xx statuses)
http_reqsTotal requests and requests per second
checksShare of your assertions that passed
iteration_durationTime for one full user journey, including think time

If thresholds are breached, k6 exits with a non-zero code, which makes it easy to fail a CI job automatically.

Step 5: Watch the Server Under Test

k6 tells you that something slowed down; the target server tells you why. During the test, watch CPU, memory, disk I/O and the database (see our bottleneck diagnosis guide):

vmstat 5
iostat -x 5
# and the database's slow query log

A dashboard from your monitoring stack makes correlation much easier (see our monitoring guide).

Test Types

TypeShapeAnswers
Smoke1–2 users, 1 minuteDoes the script and system work at all?
LoadExpected peak, held for several minutesDoes it meet targets at normal peak?
StressStep up beyond expected peakWhere does it break, and how?
SpikeSudden jump in usersDoes it survive a burst, such as a campaign launch?
SoakModerate load for hoursMemory leaks, connection exhaustion, slow degradation

Common Mistakes

  • Running k6 on the same server you test, so both compete for CPU.
  • A load generator that becomes the bottleneck: if its CPU is near 100%, the results describe the generator, not your site.
  • Testing from far away and blaming the server for network latency; generate load from a location similar to your users.
  • Only testing cached pages such as the homepage, missing the expensive logged-in, search and checkout paths.
  • Ignoring CDNs and rate limits: they may block or absorb the test; decide whether to test the origin directly.

Load Tests in CI

Run a short load test after each deploy to staging with strict thresholds. A failing threshold catches performance regressions the same way failing unit tests catch bugs. Keep the long stress and soak tests for scheduled runs.

SkyRainCloud Plans for This Workload

k6 is efficient: a 2 vCore / 8 GB load generator drives thousands of simple HTTP requests per second. Use 4–8 vCores for heavy scripts or very high request rates, and always keep the load generator separate from the server under test.

AMD EPYC 7C13 VPS

Dedicated KVM vCores on AMD EPYC 7C13 (up to 3.70 GHz) with DDR4 ECC memory, NVMe SSD and an unmetered 1 Gbps port.

PlanvCoresRAMStorageNetworkPriceGood forBuy
VPS 1 — AMD28 GB DDR4 ECC40 GB NVMe SSD1 Gbps, unmetered₹649/monthWebsites, small APIs, bots, staging and VPN serversOrder
VPS 2 — AMD416 GB DDR4 ECC80 GB NVMe SSD1 Gbps, unmetered₹1,299/monthWooCommerce, Node.js/Python backends, Docker Compose stacks, CI runnersOrder
VPS 3 — AMD832 GB DDR4 ECC150 GB NVMe SSD1 Gbps, unmetered₹2,499/monthProduction databases, high-traffic sites, multi-container appsOrder
VPS 4 — AMD1664 GB DDR4 ECC250 GB NVMe SSD1 Gbps, unmetered₹4,899/monthLarge production workloads, SaaS platforms, analytics, in-memory cachesOrder

Intel Xeon Platinum 8269CY VPS

KVM VPS on Intel Xeon Platinum 8269CY (up to 3.80 GHz Turbo) with DDR4 ECC memory, NVMe SSD, full root access and an unmetered 1 Gbps port.

PlanvCoresRAMStorageNetworkPriceGood forBuy
VPS 1 — Intel28 GB DDR4 ECC40 GB NVMe SSD1 Gbps, unmetered₹649/monthBusiness websites, small apps, scheduled jobs and botsOrder
VPS 2 — Intel416 GB DDR4 ECC80 GB NVMe SSD1 Gbps, unmetered₹1,169/monthBusiness software, mid-size databases, several sites on one serverCheck stock
VPS 3 — Intel832 GB DDR4 ECC150 GB NVMe SSD1 Gbps, unmetered₹2,249/monthERP/CRM stacks, heavier databases, multiple production appsCheck stock
VPS 4 — Intel1664 GB DDR4 ECC250 GB NVMe SSD1 Gbps, unmetered₹4,299/monthHigh-memory workloads and consolidated production serversCheck stock

Prices are monthly in INR as listed on the SkyRainCloud store (verified 2026-11-14). Stock and final pricing are shown on the product page at checkout.

Frequently Asked Questions

What is k6?
An open-source load testing tool from Grafana Labs. Tests are written in JavaScript and run from the command line, with built-in metrics, checks and pass/fail thresholds.
Why run load tests from a VPS?
A VPS has a stable, fast connection and enough CPU to generate load, and can be placed in the same region as your users. A laptop on home internet often becomes the bottleneck.
Can I run k6 on the server I am testing?
You should not: the load generator and the application compete for CPU and memory, which distorts results. Use a separate server.
How many virtual users do I need?
Enough to reproduce your expected peak concurrency, including think time. Then step higher in a stress test to find where response times or errors break your thresholds.
What are good thresholds?
Common starting points are p95 response time under 500 ms for pages or under 200–300 ms for APIs, and an error rate below 1%. Set targets that match your users' expectations.
Is it legal to load test any website?
Only test systems you own or have explicit permission to test. Unauthorised load tests can disrupt services and may be treated as an attack.
Should I load test production?
Prefer staging with production-like configuration. If you must test production, start small at a quiet time, avoid side effects and monitor closely.
Why is the average response time misleading?
Averages hide slow outliers. Percentiles such as p95 and p99 show what your slower users experience.
How do I know the load generator is not the bottleneck?
Watch its CPU and network during the test. If the generator is near its limits, use a bigger server or several generators.
Which SkyRainCloud plan suits a k6 load generator?
A 2 vCore / 8 GB AMD EPYC or Intel VPS handles most tests; use 4–8 vCores for very high request rates or complex scripts.
Instant UPI • ₹649/mo
Fast KVM Cloud Provisioning