How to debug remix latency

I've got a remix app deployed the standard way (link below), on a mysite.pages.dev domain. I've got the actual domain mysite.com with cloudflare NS, and a worker which forwards all mysite.com to mysite.pages.dev, the remix app. Sometimes requests are really quick, but sometimes it's over 800ms. Going in the logs, I see over 300ms between the "eventTimestamp" and the timestamp of the first log in my "loader". Is such a gap normal? How can I debug what's happening between the start of the "event" and reaching my loader? thanks https://developers.cloudflare.com/pages/framework-guides/deploy-a-remix-site/
Cloudflare Docs
Remix | Cloudflare Pages docs
Remix ↗ is a framework that is focused on fully utilizing the power of the web. Like Cloudflare Workers, it uses modern JavaScript APIs, and it places emphasis on web fundamentals such as meaningful HTTP status codes, caching and optimizing for both usability and performance.
1 Reply
Clown Studios
Clown Studios5w ago
the 300ms delay you're seeing between the eventTimestamp and the first log in your remix loader could be due to cold starts or routing issues within cloudflare pages. since this isn’t using workers, the delay could be caused by the edge node spinning up or your pages app going idle after some inactivity. to debug this, try enabling detailed logging for your remix app to track where the delays are occurring. you can also check the cloudflare cache configuration—make sure static assets are cached at the edge to reduce the load on your remix app for each request. if your app makes any external API calls or database queries within the loader, those could also be introducing latency. you can further reduce this by prefetching or optimizing those calls.
Want results from more Discord servers?
Add your server