---
title: "Testing storage changes"
layout: default
canonical: "/puppetdb/latest/testing_storage_changes.html"
---
# Testing storage changes
In order to keeps PuppetDB's storage code nice and fast, we have developed some
tooling to help test its performance.

## The load testing tool

The load testing (aka benchmark) tool is useful for generating sample data and
for loading the storage engine. See [the docs](load_testing_tool.markdown) for
information on its use.

## Fact storage benchmark

If you're making changes to fact storage specifically, there is a
special-purpose fact storage benchmark tool to check its performance in
different scenarios.

### Running
Run the tool with `lein run fact-storage-benchmark localhost`. Pass it the
hostname of a machine where PuppetDB is running, without ssl, on port 8080. If
you're testing a significant amount of load, you should run the benchmark on a
different machine from puppetdb.

This will automatically run test with different fact profiles and report the
time it took to store all facts, in milliseconds. For focused testing or
optimization purposes, you can select just one to run: `lein run
fact-storage-benchmark localhost medium`.

The data generated by this tool is intentionally deterministic, so that results
can be compared between subsequents runs. But it does not clear the database; if
you want to evaluate performance against an empty database, you should clear it
yourself first.

### Adding more profiles
Fact storage benchmark profiles are configured in `test-configs` var in
`src/puppetlabs/puppetdb/cli/fact_storage_benchmark.clj`. The profiles are run
in order if none is specified at the command line.


## Query performance testing with Locust

If PuppetDB is running and listening on port 8080, you can run a
simple query performance test using [Locust](https://locust.io/) like
this:

```
locust/run_load_test
```

See `locust/run_load_test --help` for some additional
information.

Dependencies are installed during the run, but if you want 
to install dependencies only for the current user you can run
`pip install --user locust pyyaml`, which will install to
~/.local, in which case you'll need to make sure the relevant
`site-packages` dir in there is in your `PYTHONPATH`  (and `bin` dir
is in your `PATH`).
