{"id":3543,"library":"locust-plugins","title":"Locust Plugins","description":"Locust Plugins is a collection of useful extensions for Locust, the open-source load testing tool. It provides implementations for various non-HTTP protocols like Playwright, Selenium/Webdriver, Kafka, FTP, and Telnet 3270, as well as enhanced reporting capabilities for TimescaleDB, Grafana, and Azure Application Insights. The library is currently at version 5.0.0 and maintains an active development cycle, often aligning with updates to Locust core.","status":"active","version":"5.0.0","language":"en","source_language":"en","source_url":"https://github.com/SvenskaSpel/locust-plugins","tags":["locust","load testing","performance testing","plugins","extensions","playwright","selenium","webdriver","kafka","ftp","mqtt","socketio","rest","timescale","grafana","application insights"],"install":[{"cmd":"pip install locust-plugins","lang":"bash","label":"Install stable version"},{"cmd":"pip install 'locust-plugins[all]'","lang":"bash","label":"Install with all optional dependencies (e.g., Playwright, Selenium)"}],"dependencies":[{"reason":"Core dependency as it provides extensions for Locust.","package":"locust","optional":false},{"reason":"Python 3.10 or newer is required.","package":"python","optional":false}],"imports":[{"symbol":"PlaywrightUser","correct":"from locust_plugins.users.playwright import PlaywrightUser"},{"symbol":"Timescale","correct":"from locust_plugins.listeners.timescale import Timescale"},{"symbol":"ApplicationInsights","correct":"from locust_plugins.listeners.appinsights import ApplicationInsights"},{"symbol":"FtpUser","correct":"from locust_plugins.users.ftpuser import FtpUser"},{"note":"MqttUser was moved into Locust core in locust-plugins 5.0.0 and Locust 2.41.0. Import directly from `locust.contrib.mqtt` instead.","wrong":"from locust_plugins.users.mqttuser import MqttUser","symbol":"MqttUser","correct":"from locust.contrib.mqtt import MqttUser"},{"note":"SocketIOUser was moved into Locust core in locust-plugins 5.0.0 and Locust 2.39.0. Import directly from `locust.contrib.socketio` instead.","wrong":"from locust_plugins.users.socketio import SocketIOUser","symbol":"SocketIOUser","correct":"from locust.contrib.socketio import SocketIOUser"},{"note":"RestUser was moved into Locust core in locust-plugins 5.0.0. Import directly from `locust.contrib.rest` instead.","wrong":"from locust_plugins.users.restuser import RestUser","symbol":"RestUser","correct":"from locust.contrib.rest import RestUser"}],"quickstart":{"code":"from locust import task, between\nfrom locust_plugins.users.playwright import PlaywrightUser\n\nclass MyPlaywrightUser(PlaywrightUser):\n    host = \"https://www.google.com\"\n    wait_time = between(2, 5)\n\n    @task\n    async def search_for_locust(self):\n        page = self.page  # Access the Playwright page object\n        await page.goto(self.host)\n        await page.fill('textarea[name=\"q\"]', \"Locust load testing\")\n        await page.press('textarea[name=\"q\"]', 'Enter')\n        await page.wait_for_selector(\"#search\"); # Wait for search results\n        await page.screenshot(path=\"locust_search.png\")\n        self.environment.events.request.fire(\n            request_type=\"Playwright\",\n            name=\"/search\",\n            response_time=1000, # Dummy response time\n            response_length=100,\n            context={\n                \"user\": self.id\n            },\n            exception=None,\n        )\n","lang":"python","description":"This quickstart demonstrates a basic PlaywrightUser, launching a browser, navigating to Google, performing a search, and taking a screenshot. It then manually fires a request event for Locust statistics."},"warnings":[{"fix":"Update your imports to `from locust.contrib.mqtt import MqttUser`, `from locust.contrib.socketio import SocketIOUser`, and `from locust.contrib.rest import RestUser` respectively. Ensure your Locust version is compatible (Locust 2.41.0+ for MqttUser, 2.39.0+ for SocketIOUser).","message":"As of `locust-plugins` version 5.0.0, the `MqttUser`, `SocketIOUser`, and `RestUser` classes have been removed from this library. They are now part of Locust core.","severity":"breaking","affected_versions":">=5.0.0"},{"fix":"Refer to the official Locust documentation for the updated `--profile` argument usage directly within Locust.","message":"The `--profile` command-line argument was removed in `locust-plugins` 4.7.0. It has been integrated into Locust core functionality.","severity":"breaking","affected_versions":">=4.7.0"},{"fix":"Optimize tests by blocking unnecessary resources (e.g., images, third-party scripts). Scale by using more Locust worker instances across multiple machines instead of increasing the number of users per worker (e.g., limit to 4-5 browser users per worker).","message":"User types like `PlaywrightUser` and `WebdriverUser` (Selenium) are resource-intensive. Running too many concurrent browser instances per worker can lead to high CPU usage and degraded performance.","severity":"gotcha","affected_versions":"All"},{"fix":"Instead, implement event-driven callbacks (e.g., `on_message()`) to handle incoming data. This aligns with Locust's gevent-based concurrency model and prevents blocking the entire worker process.","message":"When implementing custom non-HTTP User classes (or using older versions of `SocketIOUser`), avoid directly calling blocking receive methods (e.g., `self.ws.recv()`).","severity":"gotcha","affected_versions":"All (conceptual)"},{"fix":"Follow the setup instructions in the `locust-plugins` documentation for Timescale/Grafana integration, typically involving `docker-compose` for a quick setup. Activate with `locust --timescale ...`","message":"For logging and graphing results using TimescaleDB and Grafana, ensure you configure the `--timescale` argument when running Locust and have a TimescaleDB instance set up.","severity":"gotcha","affected_versions":"All"}],"env_vars":null,"last_verified":"2026-04-11T00:00:00.000Z","next_check":"2026-07-10T00:00:00.000Z"}