Skip to main content

Locust SSE User

A Locust plugin for testing Server-Sent Events (SSE) endpoints, specifically designed for LLM streaming response benchmarking.

Installation

You can install this package using uv (recommended) or pip.

Using uv

uv add locust-sse

Using pip

pip install locust-sse

Usage

Inherit from SSEUser in your locustfile.py and use the handle_sse_request method to make SSE requests.

from locust import task
from locust_sse import SSEUser

class MyLLMUser(SSEUser):
    # Set the host for the user
    host = "http://localhost:8080"

    @task
    def chat(self):
        # Example payload for a chat completion endpoint
        payload = {
            "model": "gpt-4",
            "messages": [
                {"role": "user", "content": "Tell me a joke."}
            ],
            "stream": True
        }

        # Make the SSE request
        self.handle_sse_request(
            url="/chat/completions",
            params={"json": payload},
            prompt="Tell me a joke.",
            request_name="chat_completion"
        )

Metrics

This plugin automatically tracks specific metrics relevant to LLM streaming performance and reports them to Locust.

Metric Description
TTFT Time To First Token. Measures the latency from the start of the request until the first "append" event is received.
Prompt Tokens Number of tokens in the input prompt (estimated).
Completion Tokens Number of tokens in the generated response (estimated).
Processing Time Total time taken for the entire generation process.

How Metrics Appear in Locust

These metrics are reported as separate entries in the Locust statistics table:

  • {request_name}_ttft: Latency statistics for the first token.
  • {request_name}_prompt_tokens: "Response Length" column shows token count.
  • {request_name}_completion_tokens: "Response Length" column shows token count.
  • {request_name}: The main request entry showing total duration.

Development

This project uses uv for dependency management.

# Install dependencies
uv sync

# Run tests
uv run pytest

License

This project is licensed under the MIT License - see the LICENSE file for details.

Metadata

Release files for locust-sse 0.3.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for locust-sse 0.3.1
File Size Uploaded
locust_sse-0.3.1.tar.gz 65.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for locust-sse 0.3.1
File Interpreter ABI Platform
locust_sse-0.3.1-py3-none-any.whl Python 3 none any Details

Total release size: 70.6 kB

Release files / locust_sse-0.3.1.tar.gz

Download URL locust_sse-0.3.1.tar.gz
Size 65.4 kB
Tags Source
SHA-256 checksum
How to use checksums
20a71fc32df3d51c3c356d52439828c9f0b4e21c5a8fe9d53270cde93bef4a9c
BLAKE2b-256 checksum
How to use checksums
4f5c074c082e8f5dd8521d24f4563957a52cd9feaca0f374f60353f99e207f6b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 12, 2025.

Transparency log

Release files / locust_sse-0.3.1-py3-none-any.whl

Download URL locust_sse-0.3.1-py3-none-any.whl
Size 5.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b49517fdd94b74e69b47347806b8383c16dc6c1b2c257b455307b6f3c917bc5b
BLAKE2b-256 checksum
How to use checksums
267442316a92f03245bbca5e438ee86b3650153bd3e59beddd29a4e92a261087
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 12, 2025.

Transparency log

Release history Release notifications | RSS feed

This release

0.3.1 This release

2 release files

0.3.0

2 release files

0.1.3

2 release files

0.1.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page