MongoDB open close in production (singleton or not)

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

MongoDB open close in production (singleton or not)

Sabine Manaa

Currently, I create one single Instance of Mongo when starting the Image.

| theRoot  |
theRoot := Mongo default.
theRoot open.

and use it for all requests. In my development environment that works fine.

My question is: is this the right way and will it work for production?
Or is it better to create one Mongo instance for each request (and close it after the request)?
And, btw: what would happen if I would open many Mongo connections but never close any?