Validate real-time connection performance

WebSocket Load Testing

Open hundreds of concurrent WebSocket connections and exchange messages at scale. Measure connection establishment time, message latency, and throughput under load.
loadtest.dev runs HTTP plans; this guide uses k6 directly.
Adapt this script and run it with k6 against an approved target. loadtest.dev accepts declarative GET/HEAD plans; it does not execute these scripts.
Concurrent WebSocket connection testing
Message send/receive latency tracking
Connection stability under load
Custom message payloads (JSON, binary)
Reconnection and error handling patterns
Raw WebSocket example; Socket.IO requires its own protocol handling
websocket-test.js
import ws from 'k6/ws';
import { check } from 'k6';

export const options = { vus: 100, duration: '2m' };

export default function () {
  const res = ws.connect('wss://echo.example.com', {}, (socket) => {
    socket.on('open', () => {
      socket.send(JSON.stringify({ type: 'ping' }));
    });

    socket.on('message', (msg) => {
      check(msg, {
        'got response': (m) => m.length > 0,
      });
    });

    socket.setTimeout(() => socket.close(), 10000);
  });

  check(res, { 'connected': (r) => r && r.status === 101 });
}

Frequently asked questions

Related guides

API Load Testing
Learn how to test HTTP APIs with standalone k6 scripts, measure latency and failed requests, and choose rates suited to your approved target.
GraphQL Load Testing
Adapt a standalone k6 script for GraphQL queries and mutations, validate response errors, and compare operation latency on your approved endpoint.
Spike Testing
Model a rapid traffic increase with standalone k6 stages, then observe latency, failed requests and recovery within your target’s approved load budget.

Use an HTTP plan with loadtest.dev

For estate apps, declare GET/HEAD requests to a verified hostname and submit a plan through the authenticated API.
loadtest.dev — Part of the Narduk Enterprises network