NeonN
Neon2y ago
17 replies
sad-indigo

Fly.io express app (Chicago) slow queries to Neon (Ohio)

I'm trying to figure out what the latency I'm experiencing is caused by. I'm comparing Fly postgres with Neon. The increase in latency is insane, and so I doubt the regional differences is the issue here. Cold starts aren't the issue either, since I've done queries in quick succession.

NeonDB scenario:
Fly env: Dev
Fly region: ORD (Chicago)
NeonDB region (US East - Ohio)

findOne (sequelize ORM SELECT query containing association): 197.802ms

Fly postgres scenario:
Fly env: Dev
Fly region: ORD (Chicago)
Fly postgres: ORD (Chicago)

findOne (sequelize ORM SELECT query containing association): 15.463ms

I've been able to reproduce this 10x increase in latency consistently. I've done
EXPLAIN ANALYZE
and the query is not part of the issue.

The following scenario is 10 identical queries for a non-existing row (SELECT), happening over the course of 1 minute.

From Fly (Chicago) => Neon (Ohio):
1. 203.661ms
2. 202.215ms
3. 24.295ms
4. 210.974ms
5. 207.224ms
6. 26.446ms
7. 205.322ms
8. 24.492ms
9. 24.527ms
10. 210.592ms

From local (in sweden) => Neon (Ohio):
1. 136.866ms
2. 137.751ms
3. 136.389ms
4. 135.121ms
5. 226.129ms
6. 139.663ms
7. 135.065ms
8. 139.159ms
9. 136.58ms
10. 136.821ms

Something seems way off here, and I'm unsure what it is. Fly postgres seems WAY quicker, and I'm not sure if it's because it's not using a serverless model, or if it's because of the region also being ORD (Chicago), or if it's something else.

Sorry for the long post. Any assistance would be greatly appreciated.
Was this page helpful?