Welcome to the new MongoDB Feedback Portal!
{Improvement: "Your idea"}
We’ve upgraded our system to better capture and act on your feedback.
Your feedback is meaningful and helps us build better products.
We’ve upgraded our feedback system to better capture, track, and act on your feedback. Here’s what you need to know:
|
What problem are you trying to solve? Focus on the what and why of the need you have, not the how you'd like it solved. |
I am trying to build a serverless application that connects to MongoDB while keeping database connections low, stable, and reusable, similar to what is possible with AWS Lambda or other serverless platforms. In traditional serverless environments (e.g., AWS Lambda), it is possible to:
This allows MongoDB to be used reliably even under bursty or high-concurrency workloads from Cloudflare. |
|
What would you like to see happen? Describe the desired outcome or enhancement. |
Mongo connections are reused between workers invocation like in lambda |
|
Why is this important to you or your team? Explain how the request adds value or solves a business need. |
This will open the possibility of using mongodb with cloudflare in productions for platforms that need some scale. |
What steps, if any, are you taking today to manage this problem? |
I am not using cloudflare with mongo |
We accomplish this in Lambda by creating the
MongoClientoutside the Lambda handler function (docs for reference), which we don't have a similar mechanism for with Cloudflare, but based on your feedback it seems the issue to solve for is connection management. I believe something like https://feedback.mongodb.com/ideas/CUSTOMER-I-9048 would likely service the need you're describing as well.Hi, thank you for your reply.
I tried that solution, but it still creates significantly more connections to MongoDB Atlas than AWS Lambda does.
Also, adding another layer like Durable Objects makes the system more fragile. We’ve seen in the past that when Cloudflare Durable Objects or Workers experience failures, it impacts reliability.
It would be great to have a more native and reliable approach, similar to what AWS Lambda can accomplish.
Thank you
Thanks for sharing the great feedback. What you're looking to achieve is currently possible using Cloudflare's Durable Objects to provide a stateful instance of a
MongoClient. If you're looking for an example of how to do this, I have a blog post that goes into some detail.I specifically wrote this to help users working with Cloudflare Workers, but if there other Cloudflare products where you're seeing challenges with building with MongoDB, please let us know.