Locust
FrameworkFreePython load testing framework for APIs and AI endpoints.
- Best for
- python-based user behavior definition with decorator-driven task scheduling, gevent-based greenlet concurrency for lightweight user simulation, csv and html result export with per-endpoint metrics and failure summaries
- Type
- Framework · Free
- Score
- 60/100
- Best alternative
- v0
Capabilities14 decomposed
python-based user behavior definition with decorator-driven task scheduling
Medium confidenceEnables developers to define load test scenarios as Python classes inheriting from User or HttpUser, with @task decorators specifying which methods execute and their relative weights. The framework uses Python's full expressiveness for conditional logic, loops, and state management within task definitions, avoiding XML or GUI-based test design. Task execution is scheduled by the framework's event loop, which randomly selects weighted tasks and executes them sequentially per simulated user.
Uses Python class inheritance and decorator patterns (@task) rather than XML/YAML configuration or GUI builders, allowing full language expressiveness for test logic. The @task decorator with weight parameter enables probabilistic task selection without explicit scheduling code.
More flexible than JMeter's GUI or LoadRunner's scripting because test logic is plain Python with access to standard libraries, version control, and IDE tooling; simpler than Gatling's Scala DSL for Python developers.
gevent-based greenlet concurrency for lightweight user simulation
Medium confidenceLocust uses gevent's greenlet-based concurrency model to simulate thousands of concurrent users within a single process with minimal memory overhead. Each simulated user runs in its own greenlet (lightweight pseudo-thread), and the framework uses gevent's event loop to manage I/O-bound operations (HTTP requests, network calls) without blocking. This allows a single machine to generate load equivalent to tools requiring multiple processes or machines, by avoiding OS thread overhead and context-switching costs.
Leverages gevent's greenlet model instead of OS threads or async/await, enabling thousands of concurrent users per process without thread pool exhaustion. Gevent's monkey-patching of socket operations makes standard Python HTTP libraries (requests, urllib) work seamlessly with greenlet scheduling.
More memory-efficient than thread-per-user models (JMeter, LoadRunner) and simpler than Go/Rust-based tools (Vegeta, k6) for Python developers; gevent's transparent I/O patching requires less code than explicit async/await patterns.
csv and html result export with per-endpoint metrics and failure summaries
Medium confidenceLocust exports test results to CSV and HTML formats via the stats system. CSV exports include per-endpoint metrics (request count, response times, failure count) and a summary row. HTML exports include charts (response time distribution, requests over time), tables with detailed metrics, and failure summaries. Exports are triggered via the web UI or command-line arguments (--csv, --html), and can be customized via event listeners to include additional data.
Generates both CSV (for data analysis) and HTML (for visualization) exports with per-endpoint metrics and failure summaries. HTML exports include charts and interactive tables; CSV exports are suitable for post-processing and trend analysis.
More accessible than command-line metric dumps because HTML provides visual charts; more portable than database exports because CSV/HTML are universally readable.
user distribution optimization across distributed workers using kl-divergence algorithm
Medium confidenceThe UsersDispatcher component in distributed mode calculates optimal user distribution across workers using a KL-divergence (Kullback-Leibler divergence) algorithm. Given a target user count and worker capacity estimates, the dispatcher minimizes the divergence between target and actual user distribution, ensuring balanced load generation. This is more sophisticated than round-robin allocation because it accounts for worker heterogeneity (different CPU, network capacity) and adjusts distribution dynamically as workers join/leave.
Uses KL-divergence algorithm to optimize user distribution across workers, minimizing divergence from target distribution. This is more sophisticated than round-robin because it accounts for worker heterogeneity and capacity constraints.
More intelligent than simple round-robin distribution because it optimizes for balanced load; more automated than manual allocation because it adjusts dynamically without operator intervention.
custom protocol support via user subclassing and manual request event firing
Medium confidenceLocust's User base class is protocol-agnostic; developers can subclass User and implement custom client logic for non-HTTP protocols (gRPC, WebSocket, MQTT, custom binary). Custom implementations must manually fire request_success or request_failed events to integrate with Locust's metrics system. This allows any protocol to benefit from Locust's concurrency model, statistics collection, and distributed testing infrastructure without modifying the framework.
Allows arbitrary protocol implementations by subclassing User and manually firing request events, enabling any protocol to leverage Locust's concurrency, metrics, and distributed testing infrastructure without framework modification.
More flexible than HTTP-only tools because it supports any protocol; simpler than building custom load testing frameworks because it reuses Locust's infrastructure (concurrency, statistics, distributed mode).
distributed load testing with master-worker zmq architecture
Medium confidenceLocust implements a master-worker distributed testing pattern using ZMQ (ZeroMQ) for inter-process communication. The master runner coordinates test execution, collects statistics from multiple worker processes/machines, and exposes a unified web UI. Workers spawn user greenlets and report request metrics back to the master via ZMQ publish-subscribe channels. The UsersDispatcher component uses a KL-divergence algorithm to calculate optimal user distribution across workers, ensuring balanced load generation even with heterogeneous worker capacity.
Uses ZMQ pub-sub for asynchronous metric collection rather than synchronous RPC, reducing master bottleneck. The UsersDispatcher applies KL-divergence optimization to distribute users across workers based on capacity, not just round-robin allocation.
More scalable than single-process Locust because ZMQ pub-sub avoids master becoming a bottleneck; simpler than Kubernetes-based load testing (Locust Swarm) because it requires only SSH/network access, not container orchestration.
real-time web ui with live metrics, control, and test execution management
Medium confidenceLocust provides a Flask-based web UI (accessible at http://localhost:8089 by default) that displays real-time request statistics, response time distributions, and failure rates. The UI allows operators to start/stop tests, adjust user count and spawn rate without restarting, and download results as CSV/HTML. The backend exposes a REST API that the React frontend consumes; the UI updates via WebSocket or polling to reflect live metrics from the runner and stats system.
Integrates Flask backend with React frontend and WebSocket/polling for live updates, allowing test control and monitoring from a single browser interface. The REST API enables programmatic test orchestration and result retrieval without CLI dependency.
More accessible than command-line-only tools (Apache Bench, wrk) because non-technical users can operate tests via UI; more lightweight than enterprise tools (LoadRunner, Neoload) because it's browser-based without requiring agent installation.
comprehensive request statistics collection with response time percentiles and failure tracking
Medium confidenceLocust's RequestStats system collects detailed metrics for every request: response time, status code, request/response size, and failure reason. Statistics are aggregated per endpoint and globally, with percentile calculations (p50, p95, p99) computed incrementally to avoid storing all response times. The stats system supports custom aggregation via events (request_success, request_failed) and exports results to CSV, HTML, or JSON formats. Failure tracking includes categorization by error type (timeout, connection error, HTTP 5xx, etc.) for root-cause analysis.
Implements incremental percentile calculation using histogram binning or T-Digest to avoid storing all response times, reducing memory overhead. Failure categorization by error type (timeout, connection error, HTTP status) enables root-cause analysis without post-processing.
More detailed than simple throughput metrics (requests/sec) because it captures percentile distributions; more memory-efficient than storing all response times because it uses approximate percentile algorithms.
event-driven hook system for test customization and extensibility
Medium confidenceLocust exposes an event system (EventHook pattern) that fires events at key lifecycle points: test_start, test_stop, request_success, request_failed, user_add, user_remove, etc. Developers can register listeners to these events to inject custom logic: logging, metrics collection, dynamic test adjustments, or integration with external systems. Events are fired synchronously from the runner/user code, allowing listeners to modify test behavior or collect supplementary data without modifying core framework code.
Implements a publish-subscribe event system where listeners register for specific events and execute custom logic synchronously. Events are fired at framework lifecycle points (test_start, request_success, user_add) without requiring subclassing or monkey-patching.
More flexible than callback-based approaches because events are decoupled from core logic; simpler than plugin systems because it requires only function registration, not package discovery or interface implementation.
load shaping with custom user ramp-up/ramp-down curves and dynamic load profiles
Medium confidenceLocust supports load shaping via the LoadShape class, allowing developers to define custom user count and spawn rate curves over time. Built-in shapes include StagesShape (step-wise increases) and LinearShape (linear ramp). Custom shapes implement a tick() method that returns (user_count, spawn_rate) at each time step, enabling complex load profiles: gradual ramp-up, plateau, spike tests, or realistic traffic patterns. The runner polls the shape at regular intervals and adjusts user count dynamically without stopping the test.
Implements load shaping via a LoadShape class with a tick() method that returns user count and spawn rate at each interval, allowing arbitrary load curves without configuration files. Built-in shapes (StagesShape, LinearShape) provide common patterns; custom shapes enable complex profiles.
More flexible than fixed user count because it supports dynamic load adjustment; simpler than external orchestration (Kubernetes HPA) because load shaping is defined in Python code alongside test logic.
http client abstraction with standard and fast variants for protocol flexibility
Medium confidenceLocust provides HttpUser base class that wraps the requests library, and FastHttpUser that uses a custom HTTP client (locust.contrib.fasthttp) optimized for high-throughput scenarios. Both clients support cookies, authentication, custom headers, and request/response inspection. The HTTP client is abstracted to allow custom protocol implementations: developers can subclass User and implement custom client logic (gRPC, WebSocket, custom binary protocols) by overriding the client attribute and firing request events manually.
Provides two HTTP client variants: HttpUser (requests-based, feature-complete) and FastHttpUser (custom optimized client for high throughput). The User base class is protocol-agnostic, allowing custom client implementations (gRPC, WebSocket) with manual event firing for metrics.
More flexible than curl/wget because it supports stateful client behavior (cookies, sessions); faster than requests library for high-throughput scenarios via FastHttpUser; more extensible than HTTP-only tools because custom protocols can be implemented.
locustfile loading and dynamic test scenario discovery from python modules
Medium confidenceLocust's main.py and argument_parser.py implement locustfile loading: the framework accepts a Python file path, imports it dynamically, and discovers User subclasses via introspection. The locustfile can define multiple User classes, each representing a different user type or scenario. The framework supports command-line options to select which User classes to run, or runs all discovered classes by default. Locustfiles can also define custom LoadShape classes and event listeners, making them self-contained test definitions.
Uses Python's importlib to dynamically load locustfiles and introspect for User subclasses, avoiding explicit registration or configuration files. Supports multiple User classes in a single file, each running concurrently with independent task logic.
More flexible than configuration-based tools (JMeter, LoadRunner) because test logic is plain Python; simpler than plugin-based discovery because it uses Python's built-in introspection without requiring interface implementation.
command-line interface with argument parsing for test configuration and execution control
Medium confidenceLocust's argument_parser.py provides a comprehensive CLI with options for locustfile path, target URL, user count, spawn rate, test duration, distributed mode configuration, and output formats. The CLI supports both short and long option names, environment variable overrides, and configuration file loading. Arguments are parsed into an Options object that is passed to the Environment and runners, controlling test execution without code changes.
Implements a comprehensive argument parser with support for environment variable overrides and configuration file loading, allowing test execution without code changes. Arguments are parsed into an Options object that controls runner behavior and test parameters.
More flexible than hardcoded test parameters because CLI arguments allow dynamic configuration; simpler than external orchestration tools because configuration is built-in to the framework.
open-source load testing framework
Medium confidenceLocust is an open-source load testing framework that allows developers to define user behavior in Python code, enabling scalable and distributed testing of web applications and APIs under realistic traffic conditions.
Locust uniquely allows the definition of test scenarios as Python programs, offering greater flexibility compared to traditional GUI-based tools.
Unlike traditional load testing tools, Locust's Python-based approach provides more expressiveness and scalability for defining complex user behaviors.
Capabilities are decomposed by AI analysis. Each maps to specific user intents and improves with match feedback.
Related Artifactssharing capabilities
Artifacts that share capabilities with Locust, ranked by overlap. Discovered automatically through the match graph.
nicegui
Create web-based user interfaces with Python. The nice way.
ai-goofish-monitor
基于 Playwright 和AI实现的闲鱼多任务实时/定时监控与智能分析系统,配备了功能完善的后台管理UI。帮助用户从闲鱼海量商品中,找到心仪产品。
lm-evaluation-harness
EleutherAI's evaluation framework — 200+ benchmarks, powers Open LLM Leaderboard.
Streamlit
Turn Python scripts into web apps — declarative API, data viz, chat components, free hosting.
web-eval-agent
An MCP server that autonomously evaluates web applications.
streamlit
A faster way to build and share data apps
Best For
- ✓Python developers building load tests for APIs, web services, and AI inference endpoints
- ✓Teams wanting version-controlled, code-reviewed test scenarios
- ✓Projects requiring dynamic test logic based on response data or external state
- ✓Teams with limited load testing infrastructure wanting to maximize concurrency per machine
- ✓Testing I/O-bound services (APIs, inference servers) where greenlet overhead is negligible
- ✓Cost-conscious organizations testing at scale without dedicated load testing clusters
- ✓Teams generating reports for management or stakeholders
- ✓Organizations tracking performance trends over time
Known Limitations
- ⚠Non-Python developers must learn Python syntax; no visual test builder alternative
- ⚠Task weight distribution is static per class definition; dynamic weight adjustment requires code changes
- ⚠Synchronous task execution per user means blocking I/O in tasks can reduce concurrency efficiency
- ⚠CPU-bound tasks within user code block the entire greenlet pool; true parallelism requires distributed mode
- ⚠Greenlet context switching adds ~1-5ms latency per I/O operation compared to native async/await in some scenarios
- ⚠Memory per greenlet (~50-100KB) means 10,000 users consume ~500MB-1GB base memory before request overhead
Requirements
Input / Output
UnfragileRank
UnfragileRank is computed from adoption signals, documentation quality, ecosystem connectivity, match graph feedback, and freshness. No artifact can pay for a higher rank.
About
Open-source load testing framework written in Python that allows defining user behavior with code. Scalable and distributed, it supports testing AI API endpoints, LLM inference servers, and ML model serving infrastructure under realistic traffic.
Categories
Alternatives to Locust
See all alternatives to Locust→Are you the builder of Locust?
Claim this artifact to get a verified badge, access match analytics, see which intents users search for, and manage your listing.
Get the weekly brief
New tools, rising stars, and what's actually worth your time. No spam.
Data Sources
Looking for something else?
Search →