22
33Use SSH transport when PostgreSQL and host fact collection run on a remote
44server while ` pg_perf_bench ` , ` pgbench ` , and ` psql ` run locally. The transport
5- uses AsyncSSH and native local port forwarding; ` sshtunnel ` and server-side
5+ uses AsyncSSH for remote host operations. SQL connects directly over TCP from
6+ the load-generator host; there is no database port forwarding. Server-side
67` AcceptEnv ` changes are not required.
78
89## Execution boundary
910
1011| Operation | Location |
1112| ---| ---|
12- | PostgreSQL connection | local forwarded port |
13+ | PostgreSQL connection | direct TCP from the load generator to ` --host:-- port` |
1314| ` pgbench ` and ` psql ` | local workload-generator host |
1415| Host fact collectors | remote host |
1516| Timed ` pg_diag ` OS sampler | remote host |
@@ -50,14 +51,23 @@ disposable stands.
5051
5152## Address model
5253
53- SSH database modes use two address pairs :
54+ SSH mode separates the SQL endpoint from the host-management endpoint :
5455
55- - ` --host ` and ` --port ` define a free local bind address and port;
56- - ` --remote-pg-host ` and ` --remote-pg-port ` identify PostgreSQL as seen from
57- the SSH server.
56+ - ` --host ` and ` --port ` identify PostgreSQL or a pooler reachable directly from
57+ the machine running ` pg-perf-bench ` ;
58+ - ` --ssh-host ` and ` --ssh-port ` identify the database host used for OS metrics,
59+ fact collection and lifecycle operations.
5860
59- ` asyncpg ` , ` pgbench ` , and ` psql ` connect to the local pair. AsyncSSH forwards
60- that traffic to the remote pair. The local port must not already be in use.
61+ ` asyncpg ` , ` pgbench ` , and ` psql ` use the SQL endpoint directly. This keeps SSH
62+ forwarding and encryption out of the measured database traffic. The endpoints
63+ can differ, for example when SQL goes through HAProxy/PgBouncer while metrics
64+ are collected on the primary. Select the SSH host corresponding to the database
65+ server whose OS metrics you intend to measure.
66+
67+ The former ` --remote-pg-host ` and ` --remote-pg-port ` options are rejected before
68+ any connection is made. To migrate, remove both options and replace the old
69+ local bind address and port with the SQL endpoint reachable from the generator.
70+ A working SSH login alone does not establish database network access.
6171
6272## Read-only collection
6373
@@ -68,18 +78,16 @@ PGPASSWORD=secret pg-perf-bench collect-all-info \
6878 --ssh-user postgres \
6979 --ssh-key ~ /.ssh/pg_perf_bench \
7080 --ssh-known-hosts ~ /.ssh/known_hosts \
71- --remote-pg-host 127.0.0.1 \
72- --remote-pg-port 5432 \
73- --host 127.0.0.1 \
74- --port 55432 \
81+ --host db-host.example \
82+ --port 5432 \
7583 --user postgres \
7684 --database postgres \
7785 --pg-bin-path /usr/lib/postgresql/18/bin \
7886 --report-name ssh-facts
7987```
8088
81- Collection opens the tunnel and runs remote fact commands, but does not stop
82- PostgreSQL or install a configuration file.
89+ Collection opens a direct SQL connection and runs host fact commands over SSH.
90+ It does not stop PostgreSQL or install a configuration file.
8391
8492## Benchmark
8593
@@ -91,10 +99,8 @@ PGPASSWORD=secret pg-perf-bench benchmark \
9199 --ssh-user postgres \
92100 --ssh-key ~ /.ssh/pg_perf_bench \
93101 --ssh-known-hosts ~ /.ssh/known_hosts \
94- --remote-pg-host 127.0.0.1 \
95- --remote-pg-port 5432 \
96- --host 127.0.0.1 \
97- --port 55432 \
102+ --host db-host.example \
103+ --port 5432 \
98104 --user postgres \
99105 --database pg_perf_bench_test \
100106 --pg-data-path /var/lib/postgresql/18/main \
@@ -120,8 +126,7 @@ and use a bundled profile instead:
120126PGPASSWORD=secret pg-perf-bench benchmark \
121127 --connection-type ssh --ssh-host db-host.example --ssh-user postgres \
122128 --ssh-key ~ /.ssh/pg_perf_bench --ssh-known-hosts ~ /.ssh/known_hosts \
123- --remote-pg-host 127.0.0.1 --remote-pg-port 5432 \
124- --host 127.0.0.1 --port 55432 --user postgres \
129+ --host db-host.example --port 5432 --user postgres \
125130 --pg-data-path /var/lib/postgresql/18/main \
126131 --pg-bin-path /usr/lib/postgresql/18/bin \
127132 --database pg_perf_bench_test --allow-database-reset --reset-mode schema \
@@ -163,7 +168,7 @@ and atomically renamed to the remote cluster's `postgresql.conf` before the rese
163168sudo rule. Hardware collectors use ` sudo -n ` and fail fast when permission is
164169not available.
165170
166- The load commands always execute locally through the tunnel . The newest local
171+ The load commands always execute locally using the direct SQL endpoint . The newest local
167172pgbench is selected automatically even when the remote server is PostgreSQL
16817310–18. Concurrent CPU, RAM, disk, and network sampling executes on the remote
169174database host through the already authenticated SSH session.
@@ -176,7 +181,6 @@ database host through the already authenticated SSH session.
176181 permissions, and the installed public key;
177182- authentication failure in agent mode: verify ` SSH_AUTH_SOCK ` , ` ssh-add -l ` ,
178183 the agent lifetime, and the installed public key;
179- - local bind failure: choose an unused ` --port ` ;
180- - PostgreSQL connection failure with working SSH: verify the remote address,
181- PostgreSQL authentication, and listen rules;
184+ - PostgreSQL connection failure with working SSH: verify reachability of
185+ ` --host:--port ` from the generator, PostgreSQL authentication and listen rules;
182186- lifecycle failure: ensure ` --ssh-user ` owns or can control the cluster.
0 commit comments