3 months ago
Hi there,
We're trying to use a Postgres Planetscale instance in combination with Railway, but we're seeing high than expected network latency between the two services. Looking at our logs most of our queries in Planetscale are taking less than 1ms (there's very little data at the moment). But in Railway I cannot find a SQL statement that takes less than 40ms to complete.
For context, our application is deployed in us-west-2 and and also picked that region for Planetscale. The DB connection URL we're using is us-west-3.pg.connect.db. When I ssh into the instance and run netcat, I see its about a 13-17ms ping time. I've also tried installing pscale and running it's ping command and it confirms the latency (see below).
My questions are:
1. With a 13-17ms ping time does a 40ms floor for SQL statements make sense?
Is a 13-17ms ping time expected when the two services are in the same region?
Thank you!
=====
root@7435190a9d89:/app# pscale ping
NAME (19) LATENCY ENDPOINT TYPE
----------------------------- --------- ------------------------------------------------ -----------
AWS us-west-2 13.6ms us-west.connect.psdb.cloud direct
AWS us-west-2 14.4ms aws.connect.psdb.cloud optimized
GCP us-central1 36ms gcp.connect.psdb.cloud optimized
GCP us-central1 37.1ms gcp-us-central1.connect.psdb.cloud direct
AWS us-east-2 50.7ms aws-us-east-2.connect.psdb.cloud direct
GCP us-east4 55.8ms gcp-us-east4.connect.psdb.cloud direct
GCP northamerica-northeast1 61.3ms gcp-northamerica-northeast1.connect.psdb.cloud direct
AWS us-east-1 62.2ms us-east.connect.psdb.cloud direct
AWS ca-central-1 75.4ms aws-ca-central-1.connect.psdb.cloud direct
AWS ap-northeast-1 93.2ms ap-northeast.connect.psdb.cloud direct
GCP asia-northeast3 118.5ms gcp-asia-northeast3.connect.psdb.cloud direct
AWS eu-west-2 129.8ms aws-eu-west-2.connect.psdb.cloud direct
GCP europe-west1 134.9ms gcp-europe-west1.connect.psdb.cloud direct
AWS eu-west-1 136.8ms eu-west.connect.psdb.cloud direct
AWS eu-central-1 140.5ms eu-central.connect.psdb.cloud direct
AWS ap-southeast-2 153.5ms aws-ap-southeast-2.connect.psdb.cloud direct
AWS ap-southeast-1 165.1ms ap-southeast.connect.psdb.cloud direct
AWS sa-east-1 173.4ms aws-sa-east-1.connect.psdb.cloud direct
AWS ap-south-1 219ms ap-south.connect.psdb.cloud direct
1 Replies
3 months ago
The latency you're seeing makes sense given the setup. We don't run on AWS or GCP, so even though both services are nominally in "us-west-2", they're actually in different data centers communicating over the public internet. That 13-17ms ping time is the baseline network round-trip, and when you factor in TLS handshake overhead, connection establishment, and the actual query execution, 40ms+ for a complete SQL statement is reasonable.
If you're looking to reduce this latency, you might consider hosting your database on Railway itself using our Postgres offering, that would allow you to use private networking between your app and database, which eliminates the public internet hop entirely and typically brings query times down significantly to 1-2ms in our testing.
Status changed to Awaiting User Response Railway • 3 months ago
3 months ago
This thread has been marked as solved automatically due to a lack of recent activity. Please re-open this thread or create a new one if you require further assistance. Thank you!
Status changed to Solved Railway • 3 months ago
