D1 read replication issues

I recently gave D1 global replication a try, and here are some findings/issues: 1. Only 1 replica was created in EEUR with the primary in APAC (I live in India). 2. The first request after a cold start is always routed to the primary - even when the replica is significantly faster. This pattern keeps repeating. 3. Bookmarks change unintentionally sometimes (without a write query). Maybe Cloudflare automatically adds a bookmark after a while, but I couldn't find any related docs. Thanks in advance!
3 Replies
Himanshu
HimanshuOP3mo ago
i think replica sync is done asynchronously in the background following a write. It should be an issue only when multiple concurrent requests are being handled - not the case as I was testing alone. Also, the first cold start request served from the primary takes over 2 seconds for me, while subsequent requests from the replica take around 300 ms. Something seems off.
Chaika
Chaika3mo ago
Feedback would be better in #d1-database directly, product teams don't tend to read generic forum channels I would say though 1. APAC is the closest to you, India just isn't the best location for D1. CF talked about support for Durable Objects (and thus) D1 a while ago, but just hasn't happened 2. Yea along with what Leo said, this is an optimization: https://discord.com/channels/595317990191398933/992060581832032316/1389225814993670144. It was worse without it, way more iffy response times
Himanshu
HimanshuOP3mo ago
In my experience, without the sessions api, all queries (including cold start) took around 1 sec consistently. With the sessions api, the first query takes over 2 sec with successive queries taking around 300 ms. In both cases, the primary database is handling them, not sure why the cold start has more effect with sessions api. From cloudflare dashboard, I've confirmed I've only one replica in EEUR, with the primary in APAC. It has remained fixed since I turned on the feature. So we are dealing with syncing across a fixed number of preexisting replicas. Thanks for linking the thread. I've observed the same behavior, but the latency has worsened for the first query. I'll follow up on this issue in #d1-database .

Did you find this page helpful?