Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

We are trying to deploy mongrel instances on a machine. What is the optimal number of mongrel instances for a server? Since an instance can handle concurrent connections, I do not see any benefit in starting more than 1 per core. Any more than that and the threads will just fight for CPU. Our predecessors have assigned 10 instances for 4 cores, but I think it will just cause CPU contention. Any definitive answers / opinions?

I have seen this question: How many mongrel instances?

But it is really not specific enough.

share|improve this question
    
Is there a particular reason you want to use mongrel as opposed to Phusion Passenger? –  bwizzy Jan 12 '11 at 1:08
    
Thank you for the question, just because it is already in production and we are trying to allocate thin instances for a new server and Phusion is on our roadmap, but we cannot do immediately. Actually we are using Thin. I was reading that Thin uses Eventmachine so does not block on IO. –  Amala Jan 12 '11 at 20:37
add comment

2 Answers 2

up vote 4 down vote accepted

A coworker emailed the author of thin who confirmed 1 thin instance per core. Gets more interesting for hyperthreaded cores, but that is probably another question.

Colleagues have said that mongrel blocks on IO. Thin uses eventmachine to not block on IO and uses Mongrel as the HTTP library.

share|improve this answer
    
BTW This is all only really relevant for Rails after 2.2, before that an app instance was really single threaded and could only take one request at at time. –  Amala Jan 26 '11 at 16:20
add comment

Mongrel instances may handle concurrent connections, but are you sure that all codepaths will never block? I recall that some gems still exist which block, which could cause you trouble.

Instead of looking for hard rules, I defer to measurements in these kind of situations. Design a test which offers a reasonable approximation of expected traffic and compare different configurations.

share|improve this answer
    
OK thanks, I found some resources which say that with versions of Rails from 2.2 Rails threadsafe and will not block. But we are running 2.1.1. So far I have not seen blocking directly on IO waits like DB calls. I only see it blocking in production when the CPU is busy. –  Amala Jan 12 '11 at 16:55
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.