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.1.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.1-py3-none-any.whl (13.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: locust_on_databricks-0.2.1.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.1.tar.gz
Algorithm Hash digest
SHA256 f4c7ac0effa40bcea2aba5f25824068aba677771bf74335979f796c15f50828a
MD5 3dcdef9fccb88c5caec7e33c3fe3e160
BLAKE2b-256 6cde0c32b1ecb3988c84a406934279839b082afabf45f074544cce93582ed1b6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for locust_on_databricks-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c65b50acf8b487a8558e4f4ee0f528936d13295bc4ca47a166d6e9dd49b01283
MD5 0ce2065a5cbfc516b302c31d6ac38d58
BLAKE2b-256 d917e8a8dce6dc0354d0cae2b1e2975a06c0a4c1999f0e312d1081db7d3952fd

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