Singapore Network Latency
jaggy
PROOP

2 months ago

Hi there, I've been testing my database and my app server latency and even just running SELECT 1 takes about 6ms which is very odd since they're both on the same region.

I remove the 200ms overhead for the initial connection so these are subsequent requests.

Not sure if this is expected latency between the request. Since running multiple database queries in the same request, it adds up.

---

For additional context, I've tried both metal and non-metal builds.

I also spun up a couple of servers in different regions and it's not specific to Singapore it looks like.

Solved$10 Bounty

Pinned Solution

jaggy
PROOP

2 months ago

Alright. It seems like in my case, what's affecting it the most was PHP's Emulate Prepare Statements feature. I'm not completely sure why. For this specific one, SSL wasn't the issue since my project keeps the database connection open so there's no overhead on that end.

The latency is random between 04ms - 2ms.

4 Replies

Railway
BOT

2 months ago

This thread has been marked as public for community involvement, as it does not contain any sensitive or personal information. Any further activity in this thread will be visible to everyone.

Status changed to Open Railway 2 months ago


arisayyy
FREE

2 months ago

Hello Jaggy,

Just checking, are you using the Private Networking to connect the app server and the DB?

Attachments


jaggy
PROOP

2 months ago

Yup! Also made sure I was using internal networking in the environments.


jaggy
PROOP

2 months ago

It seems like the issue was SSL. Just testing between two fresh servers, disabling SSL reduced the latency to sub 1ms.

---

Another issue specific to my project was SSL was only adding 2ms to the latency but disabling "emulate prepares" in Laravel also added to the performance hit.

At least for now disabling SSL and enabling emulated prepares brought queries from 6 - 7ms down to sub 1ms.

---

I can't quite pin point the exact issue yet but it's one of these two, or the combination of both. Every time I'm running a deploy it goes sub 1ms to 2-3ms. It's now down from a consistent 6ms so something with these two flags fixed things.

I'll keep running tests and update this thread when I get something consistent.


jaggy
PROOP

2 months ago

Alright. It seems like in my case, what's affecting it the most was PHP's Emulate Prepare Statements feature. I'm not completely sure why. For this specific one, SSL wasn't the issue since my project keeps the database connection open so there's no overhead on that end.

The latency is random between 04ms - 2ms.


Status changed to Solved brody 2 months ago


Welcome!

Sign in to your Railway account to join the conversation.

Loading...