Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

I'm managing a bunch of sites and applications in a shared hosting, using Django via mod_wsgi. I had planned to use daemon mode from the beginning (to avoid restart problems), but ended up purchasing a plan that allows me to run a dedicated Apache instance. I kept using daemon mode for convenience, but I'm afraid it's consuming more server resources than it should (I have different projects for each site, each with its own process and process group), so I'm considering switching to embedded mode.

Would that be a sensible thing to do? I'd still be able to restart Apache anytime I need to, and I wouldn't need so many child processes and sockets (so I hope the resource usage would decrease). But I'm unsure whether or not doing so would make it more difficult to manage those sites (if I need to update one, I have to restart all) or maybe the applications won't be properly isolated from one another.

Are these problems really significant (or only a minor nuisance), are there other drawbacks I coudn't foresee? I'm looking for advice in any aspect of this setup - mainainability, performance, security etc. Tips for improving the current setup are also welcome (I know how to correctly configure a basic mod_wsgi setup, but I'm clueless about sensible values for threads, processes etc).

share|improve this question
add comment

1 Answer 1

up vote 2 down vote accepted

How many is a bunch of sites and how have you set up daemon mode?

Initial impression would be that if hosting multiple sites that you would be worse off using embedded mode because you can't individually control number of processes for each. Thus if a site only really needed a single mutithread processes, you balloon out memory usage by number of child process Apache will create for embedded mode. Multiply that out across all sites and you are likely going to be much worse off.

As a general rule I would only recommend using embedded mode if you have the one site and you very much insure that you setup Apache MPM settings up properly for that one site. The defaults in Apache are very wrong for Python web applications.

So, better to use daemon mode. One site per daemon process group and prefer single default process with minimum number of threads necessary.

Provide more information about you setup and can perhaps provide more information. Do realise though that resource usage is more to do with your specific web applications and generally not the server.

Suggest you also go watch:

http://lanyrd.com/2012/pycon/spcdg/

share|improve this answer
    
I have 2 applications (few users, many ajax calls) and 11 small sites (mostly static content, just occasional calls to django, and currently very low traffic). What worried me is that despite the low number of users the server resource usage spiked on a few occasions, and I was afraid my wsgi configuration was the culprit. But if having one process group per site is commonplace, I think I'll keep using daemon mode as you suggested and go check my application specifics (maybe the usage spiked because I didn't properly throttle my ajax requests). Thanks for the tips, I'll soon check the link. –  mgibsonbr Jun 7 '12 at 7:18
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.