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.
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.
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.