Hi,
We use dozens of databases on each of our MongoDB clusters and we've gotten to a point with both the number of databases and number of processes which are connecting to those instances that we're hitting MongoDB connection limits and it's causing a lot of problems with our design.
The way our code works is that we dynamically generate Mongoid sessions for each database, but each Mongoid session is creating its own connection to the host:port.
Does anyone have any immediate thoughts around the possibility/issues/problems of sharing the socket on a per-thread basis? I made an commit at
https://github.com/jonhyman/moped/commit/aafec12b6b1eb067dceaa6a19cc49ac2408bc308 which does this, and basic testing with lsof and dynamic sessions (in MRI Ruby 2.1.5) does show that it now only makes one connection to each host:port pair instead of N, where N is the number of sessions that point at host:port that each have a different database. It also passes all the tests.
I'm going to continue doing some testing, but if it goes well, do you think you would accept a pull request into Moped for this?
Thanks,
Jon