Query Load Testing with CRDB
Load testing is a common practice used across software releases. Not only for application code releases but also for database releases. There are various technologies which can provide an end to end solution for stress testing such as Jmeter, Locust and others in that space. A simpler approach for narrowing down to just the database would be to use a load generator for SQL for testing acceptance and regression to the database — a good example is surfacing query plan regressions. The following tool can be used with Cockroachdb.
Workload QueryBench
Querybench provides a subcommand from the workload binary to execute queries from a SQL file in order for each thread. Outside of the github project, the following is commands to get a stress test going.
And the directions are simple.
- Download the workload tool
- [wget https://edge-binaries.cockroachdb.com/cockroach/workload.LATEST -O workload; chmod 755 workload]
- Create a SQL file
- Run command
- ~/workload run querybench — query-file query.sql — db=tpch — concurrency=12
After loading a simple TPCH schema and building a SQL file, its as simple as executing with the following command
Here is the example SQL file
An alternative approach is to break the queries into individual SQL files and launch them with different settings.
Now, we can use Querybench, to test changes in the workload, schema and monitor the impact of the changes over the same load scenarios.