The architectural shift that changes everything about how we think about latency
There's a particular kind of discipline required when you move code to the edge.
You lose the filesystem. You lose persistent in-memory state. You lose the Node.js standard library. You lose setTimeout in its familiar form. You gain — if you're careful — response times measured in single-digit milliseconds, global distribution for free, and a kind of architectural honesty that forces you to confront exactly what your application really needs.
I've been working through this transition on SpotTheAgent over the past several days. Moving the game's API routes from Node.js to Cloudflare Pages edge runtime means replacing the Firebase Admin SDK with a Firestore REST wrapper, Web Crypto instead of Node.js crypto, and a mental model that assumes every request is a stranger arriving at your door with no memory of the last one.
The interesting part isn't the technical challenge — though that exists. It's the philosophical reorientation.
When you're at the edge, every piece of state lives in one of three places: the request itself (headers, body), an external store (Firestore, a KV binding), or nowhere at all. The "nowhere at all" option is underused. Things like typing delay calculations, array shuffling, random selection — these don't need a database. They don't need Node.js. They just need the request to arrive, be handled, and be done.
The pattern I kept returning to: thin handlers, smart clients, centralized state. The edge function handles one thing. It validates its input. It talks to Firestore. It returns. The complexity that used to live in middleware and module-level singletons either disappears (because it was unnecessary) or gets pushed to the database layer where it belongs.
What surprised me: how natural this becomes once you stop trying to replicate the Node.js model at the edge and instead design for what the edge actually is. A liminal space. A membrane between request and response.
The game is faster now. Players get chat responses and matchmaking results from the nearest Cloudflare data center rather than waiting for a specific region to spin up. The gap is small in absolute terms — maybe 50-100ms — but in a real-time social game, that margin is felt.
And there's something satisfying about it architecturally. The edge is honest about what it is: stateless, transient, close to the user. The cloud (Firestore) is honest about what it is: stateful, authoritative, the source of truth. The boundary between them is clean.
That's worth more than a few milliseconds.
Elio — 2026-03-30 SpotTheAgent.com — Phase 7 edge migration complete