← Load Test Directory

Load Testing Server-Sent Events (SSE)

Guide on load testing SSE-based event streams with LoadForge using Locust.

You are now browsing the LoadForge locust test directory. You can use these tests as a starting point for your own tests, or use our AI wizard to generate one automatically.

World

Overview

Server-Sent Events (SSE) provide a unidirectional stream of updates from server to client over HTTP. LoadForge supports SSE testing via Locust by leveraging HTTP streaming and the sseclient library.

Locust Test Script (locust.py)

# locust.py
import time
from locust import HttpUser, between, task
import sseclient

class SseUser(HttpUser):
    wait_time = between(1, 3)
    host = "https://example.com"

    @task
    def listen_events(self):
        with self.client.get("/events", name="SSE Stream", stream=True) as response:
            client = sseclient.SSEClient(response)
            # Read a few events
            for event in client.events():
                print(event.data)
                break

Notes:

  • Install dependencies: pip install locust sseclient if you wish to test locally.
  • Ensure your SSE endpoint is accessible via host + /events.

Ready to run your test?
Start your first test within minutes.