extremely high latency when using neon
our stack uses cf worker + hyperdrive + neon
we're are seeing some nasty latency, ranging from 1-4 seconds
we found that using hyperdrive, the walltime is ~400ms, and it worsens to 1s if using direct connection w/ or w/o pool
we checked neon's dashboard and latency seems fine < 20ms, and we tested it in <5min interval so unlikely the cold start.
can anyone please help take a look? this is very frustrating and we're seriously considering moving off neon
3 Replies
absent-sapphireOP•2w ago
@Sam gentle ping on this one
our setup is here -- https://github.com/promobase/openpromo/blob/dev/packages/web-api/src/helpers/db.ts#L11
equal-jade•2w ago
Hey! Hyperdrive is supposed to keep your database connections open for you. Assuming it's set up correctly, the delay is probably not due establishing a DB connection but due to the distance between the Cloudflare Worker (region) and your database (region). Cloudflare Workers are distributed globally.
Can you log what region your Workers are running in? I think you can get that via
You can expect sub 10 ms latency when querying Neon databases from within the same region but this quickly increases when leaving datacenter, region, and continents. Review where you're currently hosting your database. We have a latency dashboard here that visualizes this nicely: https://neon.com/demos/regional-latency
request.cf.region
in your request handler but make sure to double check 🙏You can expect sub 10 ms latency when querying Neon databases from within the same region but this quickly increases when leaving datacenter, region, and continents. Review where you're currently hosting your database. We have a latency dashboard here that visualizes this nicely: https://neon.com/demos/regional-latency
Neon Latency Dashboard
30-day average latency of Neon databases from different serverless functions.
absent-sapphireOP•2w ago
thanks -- turns out worker's in london and our DB is in us-east-2, now it's fixed:) appreciate the help