pgbench runs the same small transaction many times in parallel and reports how many transactions per second (tps) the database completes. The default transaction, similar to the TPC-B benchmark, updates three tables and inserts one row into a fourth:
| Table | Rows at scale 1 | Rows at scale 50 |
|---|---|---|
pgbench_branches |
1 | 50 |
pgbench_tellers |
10 | 500 |
pgbench_accounts |
100,000 | 5,000,000 |
pgbench_history |
0 | Grows with each transaction |
You run all commands on the App server. PGHOST, PGUSER, and ~/.pgpass from the Preparation step let pgbench connect without asking for the password.
Connect to the App server (ssh rdspg-app), then run:
time pgbench -i --fillfactor=90 --scale=50 pglab
pgbench drops old test tables, creates the four tables, generates the data, runs VACUUM, and creates the primary keys.
Run a 5-minute load test with 50 concurrent clients:
pgbench --protocol=prepared -P 30 --time=300 --client=50 --jobs=2 pglab
pgbench prints the throughput and the latency of the last interval.pgbench prints the summary. On db.t4g.micro, the result is about 337 tps with an average latency of about 148 ms.
Your numbers can be different, because db.t4g.micro is a burstable instance: its performance depends on the CPU credits that the instance has collected. Keep your result, you compare it with the second load test in step 3.4.
While the load test runs, continue with the next step to watch the database in Database Insights.
db.t4g.micro allows about 80 connections. Do not set --client higher than about 70, or pgbench fails with too many clients already.