Performance and testing

vmk8s

This page summarizes the configuration parameters and testing methods that can help optimize and validate Charmed PostgreSQL deployments. It provides operational guidelines for adjusting resource allocation profiles, applying hardware constraints, and executing functional validation tests.

Resource allocation

Charmed PostgreSQL resource allocation can be controlled via the charm’s profile config option:

juju config postgresql profile=<production|testing>
juju config postgresql-k8s profile=<production|testing>

See: System profiling

Hardware constraints

The Juju --constraints flag sets RAM and CPU limits for Juju units :

juju deploy postgresql --channel 16/stable --constraints cores=8 mem=16G
juju deploy postgresql --channel 16/stable --constraints cores=8 mem=16G --trust

Juju constraints can be set together with the charm’s profile:

juju deploy postgresql --channel 16/stable --constraints cores=8 mem=16G --config profile=testing
juju deploy postgresql-k8s --channel 16/stable --constraints cores=8 mem=16G --config profile=testing --trust

Testing your deployment

Benchmarking

For performance testing and benchmarking charms, we recommend using the Charmed Sysbench operator. This is a tool for benchmarking database applications that includes monitoring and CPU/RAM/IO performance measurement.

Smoke test

This type of test ensures that basic functionality works over a short amount of time.

One way to do this is by integrating your PostgreSQL application with the PostgreSQL Test Application , and running the “continuous writes” test:

juju run postgresql-test-app/leader start-continuous-writes

The expected behaviour is:

  • postgresql-test-app will continuously insert records into the database received through the integration (the table continuous_writes).

  • The counters (amount of records in table) will grow on all cluster members

juju add-model smoke-test

juju deploy postgresql --channel 16/stable
juju add-unit postgresql -n 2

juju deploy postgresql-test-app
juju integrate postgresql-test-app:database postgresql

# Optionally configure write speed (default is 500 miliseconds)
juju config postgresql-test-app sleep_interval=1000

juju run postgresql-test-app/leader start-continuous-writes

juju run postgresql-test-app/leader show-continuous-writes
juju add-model smoke-test

juju deploy postgresql-k8s --channel 16/stable --trust
juju scale-application postgresql-k8s 3

juju deploy postgresql-test-app
juju integrate postgresql-test-app:database postgresql

# Optionally configure write speed (default is 500 miliseconds)
juju config postgresql-test-app sleep_interval=1000

juju run postgresql-test-app/leader start-continuous-writes

juju run postgresql-test-app/leader show-continuous-writes

To stop the “continuous write” test, run

juju run postgresql-test-app/leader stop-continuous-writes

To truncate the “continuous write” table (i.e. delete all records from database), run

juju run postgresql-test-app/leader clear-continuous-writes