PostgreSQL client connection with high latency

Hi there ZeroTier community,

I am running a ZeroTier Site-to-site connection with two Ubiquiti ER-X.

  • 192.168.190.0/24 Main location with PostgreSQL database
  • 192.168.191.0/24 Secondary location with Postgre Clients

On both locations I have a fiber connection with 600 down and 300 up. Ping from Secondary location to Main location is fine.

64 bytes from 192.168.190.100: icmp_seq=1 ttl=62 time=27.3 ms
64 bytes from 192.168.190.100: icmp_seq=2 ttl=62 time=26.4 ms
64 bytes from 192.168.190.100: icmp_seq=3 ttl=62 time=28.4 ms
64 bytes from 192.168.190.100: icmp_seq=4 ttl=62 time=27.5 ms

But pgbench shows an catastrophic latency from clients on Secondary location.

Result of local pgbench on Main location with goog latency:

query mode: simple
number of clients: 10
number of threads: 1
number of transactions per client: 10
number of transactions actually processed: 100/100
latency average = 21.768 ms
tps = 459.385332 (including connections establishing)
tps = 476.277620 (excluding connections establishing)

Now the result of pgbench from client on Secondary location to the database on Main location:

query mode: simple
number of clients: 10
number of threads: 1
number of transactions per client: 10
number of transactions actually processed: 100/100
latency average = 661.524 ms
tps = 15.116615 (including connections establishing)
tps = 15.444243 (excluding connections establishing)

Do you have any ideas how I can bring down the latency within PostgreSQL? Are there any optimized settings within PostgreSQL you know of which can help me?

Thanks for your help
Michael