MongoDB: What is pooling and timeout?

So, my Passenger launched 5 instances of my Rails application

I connect to MongoDB using Connection.new ("localhost", 3000 ,: pool_size => 1 ,: timeout => 5)

Why do I need a β€œconnection pool” if I only have the overhead of running my Rails application and not a query? Why does one process require more than one connection?

And what is the purpose of the timeout? Why do I need a timeout connection? Shouldn't this continue throughout the life of Rails?

So confused ...

This question is specific to Ruby and Mongo, but I assume that it applies to other languages ​​/ databases.

+7
ruby database mongodb
source share
1 answer

Here you do not need to use the connection pool. When you use Passenger, just make sure each instance uses a separate connection by catching the start_worker_process event. This is described in the README driver.

A connection pool may be useful for certain multi-threaded applications. pool_size is the maximum number of concurrent threads that will handle the connection, and latency is the maximum number of seconds that a thread can wait for an available socket before an exception is thrown.

+3
source share

All Articles