High latency with postgres database again
kossinus
PROOP

5 months ago

Hello,

We are experiencing consistently high latency when connecting to our PostgreSQL (with PostGIS) database. Even simple queries take significantly longer than expected.

All our services (backend, frontend, and database) are hosted on Railway in the same project and region. Initially, we deployed in the US region, and later switched to Europe, but the latency issue remains unchanged.

Could you please advise if this is related to network routing, or if there are additional optimizations/configurations that we should apply on Railway?

Thank you for your support.

Solved

4 Replies

Railway
BOT

5 months ago

Hey there! We've found the following might help you get unblocked faster:

If you find the answer from one of these, please let us know by solving the thread!


5 months ago

I am not an expert with PostrgreSQL however there could be a few considerations.

1.) Are you using a connection pool? If you are not, then if you are closing and opening new connections for each query it can make the query itself seem like it is taking longer.

2.) You could check your RAM and CPU usage, and check to see if it is maxing out, if it is you might want to change the RAM and or CPU usage limits to be higher.

3.) Just make sure that your columns are properly indexed, for simple queries if you are filtering by something that is not indexed in the database it can take much longer.

If none of these apply I would be happy to help go through some other troubleshooting if there is any more info!


5 months ago

Hi there, do you have detailed logs/traces of this latency?


Status changed to Awaiting User Response Railway 5 months ago


hotwheelzcodez

I am not an expert with PostrgreSQL however there could be a few considerations.1.) Are you using a connection pool? If you are not, then if you are closing and opening new connections for each query it can make the query itself seem like it is taking longer.2.) You could check your RAM and CPU usage, and check to see if it is maxing out, if it is you might want to change the RAM and or CPU usage limits to be higher.3.) Just make sure that your columns are properly indexed, for simple queries if you are filtering by something that is not indexed in the database it can take much longer.If none of these apply I would be happy to help go through some other troubleshooting if there is any more info!

kossinus
PROOP

5 months ago

Thank you for your feedback. I will proceed with configuring the Connection Pool as recommended. However, I want to clarify that the performance issue appears to originate at the PostgreSQL database level itself.

I have developed a small application with 9 tables, and I was experiencing significant delays when querying data directly from the database. For example, executing a simple SELECT query on the "Acteur" table (which contains only 25 rows) through DBeaver or PgAdmin was taking approximately 30 seconds to 1 minute to display results. This issue began appearing after September 15th, whereas queries were executing normally before that date.

The concerning aspect was that this slowness occurred at the database level itself, even when querying directly through database management tools, before any application-level connection. This suggested a potential issue with the PostgreSQL instance configuration or resource allocation on Railway.

For context, my current configuration is:

  • CPU: 32 vCPU

  • Memory: 32 GB

What's particularly intriguing is that the delay still occurs but sometimes the delay seems correct itself without any intervention on my part. I haven't made any configuration changes, yet the queries are executing normally again. This intermittent behavior is concerning as I'd like to understand the root cause to prevent it from recurring in production.

Could you help me investigate what might have caused this temporary performance degradation? Are there any Railway infrastructure events, maintenance windows, or resource throttling mechanisms that could explain this behavior?


Status changed to Awaiting Railway Response Railway 5 months ago


Status changed to Solved kossinus 5 months ago


Loading...