Skip to main content

A Locust user subclass for testing Server-Sent Events (SSE) endpoints.

Project description

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

locust_sse-0.3.1.tar.gz (65.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

locust_sse-0.3.1-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

Details for the file locust_sse-0.3.1.tar.gz.

File metadata

  • Download URL: locust_sse-0.3.1.tar.gz
  • Upload date:
  • Size: 65.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for locust_sse-0.3.1.tar.gz
Algorithm Hash digest
SHA256 20a71fc32df3d51c3c356d52439828c9f0b4e21c5a8fe9d53270cde93bef4a9c
MD5 355312d9ba8f131d7973fb3a4c27c549
BLAKE2b-256 4f5c074c082e8f5dd8521d24f4563957a52cd9feaca0f374f60353f99e207f6b

See more details on using hashes here.

Provenance

The following attestation bundles were made for locust_sse-0.3.1.tar.gz:

Publisher: release.yml on Aleph-Alpha/locust-sse

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file locust_sse-0.3.1-py3-none-any.whl.

File metadata

  • Download URL: locust_sse-0.3.1-py3-none-any.whl
  • Upload date:
  • Size: 5.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for locust_sse-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b49517fdd94b74e69b47347806b8383c16dc6c1b2c257b455307b6f3c917bc5b
MD5 9f2633f7009d7d5b9682a417a67c036c
BLAKE2b-256 267442316a92f03245bbca5e438ee86b3650153bd3e59beddd29a4e92a261087

See more details on using hashes here.

Provenance

The following attestation bundles were made for locust_sse-0.3.1-py3-none-any.whl:

Publisher: release.yml on Aleph-Alpha/locust-sse

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page