Question

our app runs on rails 3.2.12, mongo 2.2 (will migrate to 2.4), mongomapper, and uses nginx + passenger.

if we're on a VPS with 5 GB of RAM, what's the best way to determine the optimal pool size for our application, and where do we set it?

Was it helpful?

Solution

With a web application server like Passenger, the max pool size for your MongoDB connection will be per passenger worker process since the web server is forking your entire application for each worker.

Additionally, if your app (your code) isn't spawning any threads and attempting to do work in parallel, then you can just leave your pool size at 1 since increasing it won't actually help you much in that situation.

If you are spawning threads to talk to the database then just make sure your pool size * number of passenger workers doesn't exceed the total number of connections to the database that you want (eg. pool size = 5 * passenger workers = 10 = 50 connections to MongoDB). You probably want your thread pool size and connection pool size to be fairly close to each other.

Also, bare in mind that MongoDB has a hard limit of 20k connections to a single MongoDB instance.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top