Thanks for the quick reply!
I am currently using Sidekiq (a multi-threaded worker library) that queues/performs background jobs through Redis. However, the operations that I perform are querying two mongo databases through Mongoid 3 itself.
Some queries are directly on `Mongoid.session(:default)` and `Mongoid.session(:mydb2)` (which is the Moped session I assume?) that don't go through the models to update certain collections. I store them in to global variables from an initializer in Rails, like so:
$mongo_default = Mongoid.session(:default)
$mongo_mydb2 = Mongoid.session(:mydb2)
Then I use these from within about a hundred threads to perform a lot of queries. I also do a bunch of queries through actual models (model.save/update/destroy/etc).
Now, I'm not sure but is it safe to store both sessions in these global variables and accessing them from 100 different threads? Or should I be calling `Mongoid.session(:default)` and `Mongoid.session(:mydb2)` from within each thread instead? I take it that models will just handle the thread/session thing own their own when performing operations on the databases.
Also, even though they read/write from/to the same socket, this doesn't hinder a threaded environment in terms of performance/blocking requests, does it?
Thanks again!