
Preparing to benchmark
One of the customers is implementing Fujitsu Enterprise Postgres with high availability using Mirroring Controller (MC) and Server Assistant in the AWS cloud.
To leverage the zone redundancy provided by AWS using Availability Zones (AZ) and place each of the three Fujitsu Enterprise Postgres nodes in various AZ in a region, we tested how the network latency will affect the placement of Fujitsu Enterprise Postgres nodes.
AWS claims single-digit millisecond roundtrip latency between AZs in the same Region. So, would it have any detrimental effect on the functioning of a HA cluster which would lead to unwanted failover due to network latency?
As you may be aware, one of the pre-conditions for Mirroring Controller is streaming replication configured in synchronous mode, where two-phase commit must happen to complete any DML operations.
We have used
- Operating system: Red Hat Enterprise Linux release 9.4 (Plow)
- Database: Fujitsu Enterprise Postgres 15 SP2 Advanced Edition
- vCPUs: 4
- Benchmarking tool: pgbench
- Distribution: AWS EC2 instances housed in different AZ of a region
# | Server | Role | Availability Zone |
1 | fep15sp2-coe-lab01 | Primary | us-west-2a |
2 | fep15sp2-coe-lab02 | Standby | us-west-2b |
3 | fep15sp2-coe-lab03 | Arbiter | us-west-2c |
For the initial data load, using pgbench
$ pgbench -i -s 150 testdb
-i, --initialize invokes initialization mode
-s, --scale=NUM scaling factor
Load test with (-N) to perform simple updates. The sample looks like the below:
pgbench -c 5 -j 5 -T 120 -n -N testdb
-c, --client=NUM number of concurrent database clients (default: 1)
-j, --jobs=NUM number of threads (default: 1)
-T, --time=NUM duration of benchmark test in seconds
-n, --no-vacuum do not run VACUUM before tests
-N, --skip-some-updates skip updates of pgbench_tellers and pgbench_branches (same as "-b simple-update")
To induce latency to eth0 network card, we ran ‘tc’ (Traffic Control) command, as root user, as below:
- To add latency of 50ms
tc qdisc add dev eth0 root netem delay 50ms
- To change latency to 100ms
tc qdisc change dev eth0 root netem delay 100ms
- To remove latency
tc qdisc del dev eth0 root netem
Once you altered the latency, you can verify the round-trip time (rtt) in the ping command response.
Testing
First, we ran test with five clients for pgbench — pgbench -c 5
Induced latency (ms) |
ping (rtt min/avg/ max/mdev) |
Clients | Threads per client | Duration | TPS | Transactions processed |
Write latency average (ms) |
Mirroring Controller status |
Transaction type |
nil | 0.508/ 0.935/ 1.727/ 0.358 |
5 | 2 | 120s | 856 | 102798 | 5.837 | switchable | Write only |
5 | 2 | 120s | 865 | 103810 | 5.78 | switchable | Write only | ||
5 | 2 | 120s | 811 | 97408 | 6.159 | switchable | Write only | ||
50ms | 50.633/ 51.063/ 51.732/ 0.376 |
5 | 2 | 120s | 88 | 10581 | 56.726 | switchable | Write only |
|
5 | 2 | 120s | 88 | 10607 | 56.588 | switchable | Write only | |
5 | 2 | 120s | 88 | 10638 | 56.412 | switchable | Write only | ||
100ms | 100.648/ 100.949/ 101.626/ 0.322 |
5 | 2 | 120s | 47 | 5660 | 106.092 | switchable | Write only |
5 | 2 | 120s | 47 | 5659 | 106.109 | switchable | Write only | ||
5 | 2 | 120s | 47 | 5660 | 106.009 | switchable | Write only |
We tested further, then
Next, we increased the number of clients to 50.
Induced latency (ms) |
ping (rtt min/avg/ max/mdev) |
Clients | Threads per client | Duration | TPS | Transactions processed |
Write latency average (ms) |
Mirroring Controller status |
Transaction type |
nil | 0.589/ 1.002/ 1.515/ 0.312 |
50 | 2 | 120s | 2668 | 102798 | 18.735 | switchable | Write only |
50 | 2 | 120s | 2762 | 103810 | 18.101 | switchable | Write only | ||
50 | 5 | 120s | 2647 | 97408 | 18.885 | switchable | Write only | ||
50 | 5 | 120s | 2621 | 314756 | 19.072 | switchable | Write only | ||
50ms | 50.603/ 51.072/ 51.680/ 0.277 |
50 | 5 | 120s | 847 | 101735 | 58.996 | switchable | Write only |
|
50 | 5 | 120s | 870 | 104456 | 57.458 | switchable | Write only | |
50 | 5 | 120s | 855 | 102676 | 58.45 | switchable | Write only | ||
100ms | 100.672/ 100.943/ 101.161/ 0.136 |
50 | 5 | 120s | 465 | 5586 | 107.457 | switchable | Write only |
50 | 5 | 120s | 470 | 56942 | 106.271 | switchable | Write only | ||
50 | 5 | 120s | 467 | 56183 | 106.847 | switchable | Write only |
Observations
We observed that in the cases with up to 100ms of latency in the network, the Mirroring Controller status remains
switchable, which indicates the transactions are in sync, and in case of any abnormality, the Mirroring Controller can trigger automatic failover, as expected.
Another observation to note is that as network latency increases, both the transaction processed per second (TPS) and transaction processed decrease, while write latency spikes as anticipated.
Wrapping up: key takeaways
If you consider implementing a Fujitsu Enterprise Postgres High Availability cluster across availability zones in a cloud environment, it is highly advised to conduct failover tests.
In this article, we have shown how to simulate a network latencies using the pgbench benchmarking tool and the tc qdisc netem command.