Tom provides a practical masterclass in eliminating the "distributed database tax" through session-based routing. It’s a vital guide for anyone needing to turn edge computing promises into actual millisecond gains.
Deep Dive
Prerequisite Knowledge
- No data available.
Where to go next
- No data available.
Deep Dive
Getting Low Latency Database Reads in Cloudflare D1Added:
This honestly feels like a cheat code to get really low latency database reads when you're using Cloudflare workers and a D1 database. So, you can see here I have this function and it is called get workspace billing and it's taken almost 1,200 milliseconds to execute this function. And that seems like a crazy long time considering this is just a worker hitting a D1 database. So, you would think that they're kind of co-located and that the latency there would be really low.
So, the way that we can get this down is we can come into the database and we can enable this read replicas here. And so, this is going to create replicas of your database throughout a bunch of Cloudflare locations. Now, it does give you this warning this currently in beta.
Ignore that, whatever.
So, if we come back into our logs after we have enabled our read replicas, you can see that we have this function here get workspace billing and now it's taken 214 milliseconds.
So, what's that like a five or six times decrease to execute this function? So, to enable this in your code, you do need to use sessions and luckily Drizzle ORM makes that really easy. You just need to use drizzle.db.withSession with this first unconstrained as the argument here. And I have got this working using a proxy inside of my server.ts.
So, you can see I have this function here that surrounds my whole handler run with session.
And that is going to use async local storage to keep a record of the session for that request because all of the database reads within that execution need to be done on the same session.
Related Videos
Agentforce NOW AMA: Build with React and Salesforce Multi-Framework
SalesforceDevs
490 views•2026-05-28
How agent o11y differs from traditional o11y — Phil Hetzel, Braintrust
aiDotEngineer
450 views•2026-05-28
WEB TECHNOLOGIES UNIT-2 | Degree 4th sem BCOM Computers web technologies unit-2 full explanation💯✅
LearnwithSahera
1K views•2026-05-29
More tests are always better? How to use AI to identify tests that bring little value
Alliance4Qualification
335 views•2026-05-29
Search Algorithms Explained in 60 Seconds! 🤖💨
samarthtuliofficial
218 views•2026-06-01
People of Game of Thrones using JavaScript DOM
AltCampus
296 views•2026-05-30
Introduction to Problem Solving Part - 1 | Lecture 1 | Intermediate DSA
ascensionix
107 views•2026-05-29
🚀 BCS613C Compiler Design | Module 1 to 5 Schema Evaluation 🔥 | VTU 6th Sem 💯 #VTU #bcs613c #exam
Pranavaa-y4y
104 views•2026-06-02











