Cloudflare Pages + D1 has way higher latency than expected

For Workes & Pages, what is the name of the domain?

N/A

What is the issue or error you’re encountering

I have a Remix app which does some external calls (D1 + API) which locally takes about 170 ms, but when hosted on Cloudflare Pages takes about 800 ms or more (consistently). What is the best way to debug/improve this? Can you find out the actual location of your Worker and D1 database?

What steps have you taken to resolve the issue?

My location is The Netherlands, I gave a location hint for D1 in Eastern North America (most of my clients are US based).

Ping to the US from my location should be approximately 100 ms. When I log the D1 call on Cloudflare Pages it takes 713ms (it’s JavaScript, I use performance.now() before and after the D1 call). That’s seems way more than necessary. The D1 query latency itself is very low (0 ms). Then the other API call adds 385 ms resulting in a page load of over a second, which I find too much.

Smart placement hasn’t made a difference so far. It also seems unrelated to a cold start, because it happens many times in a row.

What are my options?

3 Likes

I’m experiencing the same problem with D1(between 500 and 700 ms on a select * for a table with 5 rows and 4 columns), would love some tips from Cloudflare on how to make it workable. I understand there is some extra latency to be expected from a serverless database but 500ms is above our performance targets.

Any tips?

1 Like

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.