Single apache instance vs multiple apache instances

apache-2.2multiple-instancessaas

I work in a SaaS application built with Django (Python) and runs with Apache/mod_wsgi.

The registration site creates an apache virtual host config, wsgi and settings files. And finally restarts the apache server.

This means that every time a new user registers an account apache restarts and this affect the performance of the app for the current clients.

A possible option is to create a separate apache instance for new clients how ever this will increase too much the RAM needed for all clients.

What recommendations do you have about this?

Best Answer

The side effect of several instances is that they all can't run on the same port either.

Maybe your script can do a "apachectl configtest" to ensure the configuration is valid first (helping prevent it not starting due to error in config).

And then run apachectl graceful.

apachectl graceful: Gracefully restarts the Apache daemon by sending it a SIGUSR1. If the daemon is not running, it is started. This differs from a normal restart in that currently open connections are not aborted. A side effect is that old log files will not be closed immediately. This means that if used in a log rotation script, a substantial delay may be necessary to ensure that the old log files are closed before processing them. This command automatically checks the configuration files via configtest before initiating the restart to make sure Apache doesn't die.

apachectl configtest: Run a configuration file syntax test. It parses the configuration files and either reports Syntax Ok or detailed information about the particular syntax error.