Skip to main content

Run locust on single node or distributed on Databricks.

Project description

locust-on-databricks

Installation

pip install locust-on-databricks

Usage

OOTB Examples

For OOTB please look at examples in

  1. 01 Locust Test Single Node.py
  2. 02 Locust Test Distributed.py

The dummy example locustfile is here: locustfile.py

API Usage

Construct the runner:

from lod import LocustRunner

runner = LocustRunner(
    locustfile_path="locustfile.py",  # path to your locustfile
    # port=8089, # port is optional
)

Construct your initial swarm:

runner = runner.set_initial_swarm(
    host="https://google.com",
    user_count=10,
    spawn_rate=2,
    # run_time = "5m"
)

Start your locust server:

runner.start_locust()

Wait for running locust swarm to finish

runner.block_until_end_of_swarm(
    timeout_in_seconds=300,
    # check_every_n_seconds=5, # poll every n seconds default is 5s
)

Capture results/snapshots into a directory

This will create:

  1. request metrics csv
  2. failures csv
  3. exceptions csv
  4. html report
runner.save_artifacts(
    # save_directory="artifacts" # default is artifacts but recommended you save to volumes
    # file_prefix="" # default is empty prefix to your artifacts
)

Stop your locust server:

runner.stop_locust()

Search for "Access Locust Web UI at" in the output and open the link in your browser.

Distributed Runner

Construct a distributed runner:

runner = runner
.distributed()
.set_initial_swarm(
    host="https://google.com",
    user_count=10,
    spawn_rate=2,
    # run_time = "5m"
)

Construct a distributed runner with custom worker to core ratio:

runner = runner
.distributed(process_to_core_count_ratio=2.0)
.set_initial_swarm(
    host="https://google.com",
    user_count=10,
    spawn_rate=2,
    # run_time = "5m"
)

process_to_core_count_ratio is defaulted to 2 and it will spin up twice the number of workers as you have cores. You can tweak this as needed.

Run and stop new swarms

Run a new swarm:

runner.run_swarm(
    host="https://google.com",
    user_count=10,
    spawn_rate=2,
    # run_time = "5m"
)

Stop a running swarm

runner.stop_swarm()

Limitations

Starting a new swarm in the ui is bugged and the swarm rest api from the ui is not working.

Disclaimer

locust-on-databricks is not developed, endorsed not supported by Databricks. It is provided as-is; no warranty is derived from using this package. For more details, please refer to the license.

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_on_databricks-0.2.0.tar.gz (16.1 kB view details)

Uploaded Source

Built Distribution

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

locust_on_databricks-0.2.0-py3-none-any.whl (13.3 kB view details)

Uploaded Python 3

File details

Details for the file locust_on_databricks-0.2.0.tar.gz.

File metadata

  • Download URL: locust_on_databricks-0.2.0.tar.gz
  • Upload date:
  • Size: 16.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.8

File hashes

Hashes for locust_on_databricks-0.2.0.tar.gz
Algorithm Hash digest
SHA256 3da25dd5d898ad54effa0db4aa9573a03452dc799dab3ed609c8358126417439
MD5 c960723eb2e44040243b5dd517419a4b
BLAKE2b-256 de1653e8e27213ca57d3c4dd6db2bb5c302e6ef53bb7b5878c315eacd617c3c9

See more details on using hashes here.

File details

Details for the file locust_on_databricks-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for locust_on_databricks-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 edbb77fb6375d1927f521802fd29e80126584836a35297b40f84c6f951fca8ec
MD5 e4ebe2a856beacb8b88e8bcf513de2a4
BLAKE2b-256 3e63b7f7fd1c2d5ba554d319edc6a09954145dd2b1f89920b3121ecf94883241

See more details on using hashes here.

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