2

I've this config in my apache2.conf

<IfModule mpm_prefork_module>
StartServers          5
MinSpareServers       5
MaxSpareServers      10
MaxClients          150
MaxRequestsPerChild   0
</IfModule>
# worker MPM
# StartServers: initial number of server processes to start
# MaxClients: maximum number of simultaneous client connections
# MinSpareThreads: minimum number of worker threads which are kept spare
# MaxSpareThreads: maximum number of worker threads which are kept spare
# ThreadsPerChild: constant number of worker threads in each server process
# MaxRequestsPerChild: maximum number of requests a server process serves
<IfModule mpm_worker_module>
StartServers          2
MaxClients          15
MinSpareThreads      4
MaxSpareThreads      5
ThreadsPerChild      15
MaxRequestsPerChild   50000
</IfModule>

Now I'm confused here.

  • Which module gets loaded on which conditions?
  • The phusion guys have suggested to use the worker module. Since both are present in apache conf file, do I have to comment the mpm_prefork_module or leave it as it is?

Following is my passenger conf file for apache:

LoadModule passenger_module /usr/lib/ruby/gems/1.8/gems/passenger-2.2.4/ext/apache2/mod_passenger.so
PassengerRoot /usr/lib/ruby/gems/1.8/gems/passenger-2.2.4
PassengerRuby /usr/bin/ruby1.8
PassengerMaxPoolSize 3
PassengerPoolIdleTime 999999
RailsFrameworkSpawnerIdleTime 0
RailsAppSpawnerIdleTime 0
  • I'm running just a single Rails 2.3.2 app on 256MB slice at slicehost. I'm not quite satisfied with the performance yet. Are the settings above are any good??

3 Answers 3

2

a. run httpd/apache/httpd2/apache2 -l to see which mpm is loaded (usually is prefork though)
b. to get the worker module you have to install it, I've never done it before though, but I know its an either or proposition, they cannot co-exist
c. If you are anticipating any kind of traffic make sure to set MaxClients (in prefork configuration) to about 20 (starting out) or else your app/passenger will crap out in periods of high traffic
d. For passenger settings, I'd start with

PassengerMaxPoolSize 2
PassengerPoolIdleTime 0
RailsFrameworkSpawnerIdleTime 0
RailsAppSpawnerIdleTime 0

What this does is keep the Framework spawner, App spawner and App instances in memory for the longest possible time, so it does not have to respawn an app instance or the framework after a period of inactivity (if your site is not high traffic). This is as close to running an always-on mongrel-type setup as you'll get.

3
  • Too tee off Hongli's answer below ... to find out what mpm you're running just run apache/httpd/apachectl/(whatever your apache command is) -l and you will see the module listed. enjoy.
    – concept47
    Aug 29, 2009 at 10:14
  • I'm on Ubuntu Intrepid and when I issue the command as you've suggested, httpd/apache/httpd2/apache2 -l The cmd not found. I googled and got another cmd, apache2 -l This too doesn't work? Is is supposed to work or is there other cmd to find out which MPM is loaded with apache?
    – millisami
    Aug 29, 2009 at 11:09
  • there are many ways to invoke apache from the command line thats why I put all of them separated by slashes. The slashes mean that you should try each of them till you find one that works on your machine. apachectl -l or apache2ctl -l might also work.
    – concept47
    Aug 31, 2009 at 5:59
1

Whether Apache uses the prefork MPM or the worker MPM is a compile time option. There's no way to change it at runtime so you can't load an MPM.

The directive means "if the current MPM is xxx, then use the configuration inside this block, otherwise ignore this block completely".

So if you want to use the worker MPM then you must uninstall the prefork version and install the worker version.

2
  • Just to clarify this for passers-by: I know of at least one distribution that lets you choose the worker in the init script. Red Hat EL (and thus CentOS et al) supply /usr/sbin/httpd, /usr/sbin/httpd.worker and /usr/sbin/httpd.event. The active MPM can be set in /etc/sysconfig/httpd.
    – Martijn
    Mar 5, 2013 at 15:44
  • Debian/Ubuntu lets you install a different MPM using the packages apache2-mpm-* . Installing one with uninstall the others.
    – Kevin
    Dec 2, 2013 at 23:11
0

Generally, people ask when their VPS starts hitting swap, is that your situation? This thread is pretty helpful re, using "free" and "top" and switching to MPM worker

http://forum.slicehost.com/comments.php?DiscussionID=3313

These are informative about the settings that don't get talked about much

http://wiki.ninjafocus.net/Ruby_on_Rails

http://programming-gone-awry.blogspot.com/2009/06/how-to-save-much-ram-when-running-rails.html

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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