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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file locust_sse-0.3.0.tar.gz.
File metadata
- Download URL: locust_sse-0.3.0.tar.gz
- Upload date:
- Size: 64.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
07aca03683026eefb500101cb59e9f80413649c822a3ff942b1c271a1e5b170b
|
|
| MD5 |
53f5356811a1d9cfae346940e44251b3
|
|
| BLAKE2b-256 |
5067b73e6b030f0e703e23ae47bfe8e45299e3590b24057ae1eddfeec123b6d3
|
Provenance
The following attestation bundles were made for locust_sse-0.3.0.tar.gz:
Publisher:
release.yml on Aleph-Alpha/locust-sse
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
locust_sse-0.3.0.tar.gz -
Subject digest:
07aca03683026eefb500101cb59e9f80413649c822a3ff942b1c271a1e5b170b - Sigstore transparency entry: 756939080
- Sigstore integration time:
-
Permalink:
Aleph-Alpha/locust-sse@4916ae109c5e991f74ba738235d449c30fccf4c1 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/Aleph-Alpha
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@4916ae109c5e991f74ba738235d449c30fccf4c1 -
Trigger Event:
push
-
Statement type:
File details
Details for the file locust_sse-0.3.0-py3-none-any.whl.
File metadata
- Download URL: locust_sse-0.3.0-py3-none-any.whl
- Upload date:
- Size: 4.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0abecc2416cb58850479eb3d4b0269577d197528943ab334ac519fff624050a5
|
|
| MD5 |
b7059e1a3b630c8a9e4b4904c2eee3ad
|
|
| BLAKE2b-256 |
73e33aa9e2d6c99d1e9e988d1ee3779320d125507bd677df5b76d82246aaffe4
|
Provenance
The following attestation bundles were made for locust_sse-0.3.0-py3-none-any.whl:
Publisher:
release.yml on Aleph-Alpha/locust-sse
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
locust_sse-0.3.0-py3-none-any.whl -
Subject digest:
0abecc2416cb58850479eb3d4b0269577d197528943ab334ac519fff624050a5 - Sigstore transparency entry: 756939084
- Sigstore integration time:
-
Permalink:
Aleph-Alpha/locust-sse@4916ae109c5e991f74ba738235d449c30fccf4c1 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/Aleph-Alpha
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@4916ae109c5e991f74ba738235d449c30fccf4c1 -
Trigger Event:
push
-
Statement type: