3 months ago
In one project, I have laravel project and a postgres database.
I wrote a script to check the latency between the app and the database.
To perform "select 1" against the database I got this:
High latency detected (15.886735916138ms average)
I then created a new project and repeated the steps:
The second project:
=== Analysis ===
Latency is acceptable (2.5292539596558ms)
I have witnessed this before on previous projects, sometimes the projects are noticeably slower.
All resources within the EU area.
2 Replies
3 months ago
After doing a little more debugging I am exploring a new idea.
Postgres database is created with the following template:
https://railway.com/deploy/postgres-pgbouncer
Regardless of whether you're connecting to the PgBouncer or PostgreSQL directly, have a larger latency for some reason.
I can't see any differences between the PostgreSQL instances created directly and ones created with this template.
3 months ago
Okay from what I can tell it's relatively random. If the services and the database service get put on the same computer, you see a much lower latency. But this doesn't happen every time and that's when you get the larger latency. It's completely random but it loads of 15ms queries, adds up quite quickly.