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.
Concurrent WebSocket connection testing
Message send/receive latency tracking
Connection stability under load
Custom message payloads (JSON, binary)
Reconnection and error handling patterns
Compatible with Socket.io and raw WebSockets
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
Load test REST and GraphQL APIs at a fixed request rate, with per-second latency and error charts.
GraphQL Load Testing
Load test your GraphQL API with realistic queries and mutations. Measure resolver performance and find N+1 query bottlenecks.
Spike Testing
Test how your application handles sudden traffic spikes. Simulate flash sales, viral moments, and DDoS-like scenarios safely.

Run this as a plan

Put the scenario in your app's Config/load-plan.json and run it from the narduk-app CLI.
loadtest.dev — Part of the Narduk Enterprises network