Fly Postgres Connections to Replicas Slow

Tried running a similar command from an app server in ams and it has an 800ms delay.

root@e2860e0a563d28:/code# export PGPASSWORD=(meow)
root@e2860e0a563d28:/code# time psql -h "splashcat-db.flycast" -p 5433 -c "select state, count(*) from pg_stat_activity group by state" -U postgres
 state  | count 
--------+-------
        |     4
 active |     1
 idle   |     6
(3 rows)


real	0m0.800s
user	0m0.035s
sys	0m0.009s
root@e2860e0a563d28:/code# echo $FLY_REGION
ams

Also out of curiosity, I ran this same command but through the .internal host instead so flycast doesn’t get involved and that seems to help.

root@e2860e0a563d28:/code# time psql -h "splashcat-db.internal" -p 5433 -c "select state, count(*) from pg_stat_activity group by state" -U postgres
 state  | count 
--------+-------
        |     4
 active |     1
 idle   |     8
(3 rows)


real	0m0.264s
user	0m0.027s
sys	0m0.011s

I don’t know if I can eliminate flycast though as tmk it was created for Postgres?

Also ran the same few commands in iad. I tried both ports 5432 and 5433 for this but only included 5433 below as the results were practically the same.

root@6e8245ddc49987:/code# time psql -h "splashcat-db.flycast" -p 5433 -c "select state, count(*) from pg_stat_activity group by state" -U postgres
 state  | count 
--------+-------
        |     4
 active |     1
 idle   |     4
(3 rows)


real	0m0.065s
user	0m0.036s
sys	0m0.005s
root@6e8245ddc49987:/code# time psql -h "splashcat-db.internal" -p 5433 -c "select state, count(*) from pg_stat_activity group by state" -U postgres
 state  | count 
--------+-------
        |     4
 active |     1
 idle   |     4
(3 rows)


real	0m0.040s
user	0m0.022s
sys	0m0.013s
root@6e8245ddc49987:/code# echo $FLY_REGION
iad