pgbench - Performance benchmark for PostgreSQL¶
pgbench is a simple program for running benchmark tests on PostgreSQL. It runs the same sequence of SQL commands over and over, possibly in multiple concurrent database sessions, and then calculates the average transaction rate (transactions per second). By default, pgbench tests a scenario that is loosely based on TPC-B, involving five SELECT, UPDATE, and INSERT commands per transaction. However, it is easy to test other cases by writing your own transaction script files.
With the pgbench benchmark, you can benchmark your PostgreSQL database, which can both run in the same Kubernetes cluster as kubestone, or anywhere else, as long as it's reachable.
Mode of operation¶
In the pgbench CR, you need to specify the connection details to your PostgreSQL database in the
postgres section, containing the
database, and your
Kubestone then generates a single Kubernetes job from the CR. The pod behind the job will have an init container that runs the
pgbench -i initialization command, and a main container that will run the actual benchmark. For these containers, you can use any options described in the official pgbench documentation with
You can find configuration example in the GitHub repository.
To run the example CR, you need the corresponding PostgreSQL database. You can create it in the same Kubernetes cluster with the following command:
kubectl create --namespace kubestone -f https://raw.githubusercontent.com/xridge/kubestone/master/tests/e2e/conf/postgres.yaml
Naturally, you can deploy postgres to a separate namespace, too, but then don't forget to update the
postgres.host in the CR accordingly.
Now, you can run the sample benchmark:
kubectl create --namespace kubestone -f https://raw.githubusercontent.com/xridge/kubestone/master/config/samples/perf_v1alpha1_pgbench.yaml
Please refer to the quickstart guide for details on generic principles and setup of Kubestone.
The complete documentation of the pgbench CR can be found in the API Docs.
pgbench is part of PostgreSQL, which is licensed under the PostgreSQL License, a liberal Open Source license, similar to the BSD or MIT licenses.