Disclaimer; I’m not affiliated with MongoDB - just a “normal” customer.
I hope/think MongoDB is really busy at the moment, making the official MongoDB driver compatible with the worker’s environment. Cloudflare recently shared this post, and the feature set is impressive. Combined with Cloudflare’s work on Hyperdrive - it seems like a lot of effort is being put into how to make initial connections fast. From the article:
…it maintains a set of regional database connection pools across Cloudflare’s network, so a Cloudflare Worker avoids making a fresh connection to a database on every request. Instead, the Worker can establish a connection to Hyperdrive (fast!), with Hyperdrive maintaining a pool of ready-to-go connections back to the database. Since a database can be anywhere from 30ms to (often) 300ms away over a single round-trip (let alone the seven or more you need for a new connection), having a pool of available connections dramatically reduces the latency issue that short-lived connections would otherwise suffer.
I hope MongoDB is actively working on:
- Make the native node.js driver work on workers
- In cooperation with Cloudflare offer “regional database connection pools”, so a Cloudflare Worker avoids making a fresh connection on every request.
Hopefully, we soon get more information - so MongoDB can be an attractive alternative to Hyperdrive/D1. Would be such a shame if MongoDB misses the open window they have right now to be an early adopter of the edge.