Skip to main content

Add your description here

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.1.1.tar.gz (64.2 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.1.1-py3-none-any.whl (4.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: locust_sse-0.1.1.tar.gz
  • Upload date:
  • Size: 64.2 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.1.1.tar.gz
Algorithm Hash digest
SHA256 81c42f9213fd60dea2f01d480eee4df8d805a6277c1403696c630ad58b7389d5
MD5 bb9a61262aea0b807c04e6bf3b18950b
BLAKE2b-256 08c4a7abad2bba5a2e51af6008f2bf4bfdaa202c2f03840557c80faede09922b

See more details on using hashes here.

Provenance

The following attestation bundles were made for locust_sse-0.1.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.1.1-py3-none-any.whl.

File metadata

  • Download URL: locust_sse-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 4.3 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.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ee0a55a256c6a0ad601c6a8afc605218ebef0d816284912ea6dc2194546a6885
MD5 ca05602df6aec9eaa7f9dc69de91f324
BLAKE2b-256 8b0c279f2ae8f0bfbb458f306cc1a72361c37f9c0a747382bbea99e8259ef921

See more details on using hashes here.

Provenance

The following attestation bundles were made for locust_sse-0.1.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