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.

I have an Apache server that is serving a django application with mod_wsgi. I'm wondering if there is a simple way to throttle requests at the apache level based on the machine's load.

Ideally I want an apache module that if the load is below a certain figure, everything works OK. However if the load is above something, then X% of IP addresses will be served the static html page for Y minutes. Does that software exist?

We are looking for a "poor man's throttling system". Something quick and easy we can drop in. Throttling based on machine load is good because it means things will eventually return to normal.

Our web application does a lot of processing, so things that limit bandwidth aren't going to pick up on this, it's not bandwidth we want to 'throttle' but, requests. Ideally we'd want some existing requests (i.e. based on IP address) to be able to continue for a certain amount of time (so they can finish doing their stuff).

share|improve this question
    
Hello, did you manage to achieve your goal? –  Eric DANNIELOU Nov 21 '13 at 9:19
add comment

2 Answers

I've never set this up myself, and I appreciate this isnt exactly what you are looking for (ie its not an apache module) but there is a tool called traffic control. Given that tc is invoked by a simple command line, it seems likely that you can integrate it into your own script, and instigate the throttling you want based on the load output from top, or whatever else you have monitoring load.

There's an example script on this page: http://wiki.openvz.org/Traffic_shaping_with_tc

share|improve this answer
add comment

Disclaimer: I'm a varnish fanboy.

I'm not aware of any official apache module doing this natively.

Varnish can serve static html if backend (django) does not respond within specified time.

If you really want to serve static file to 10% of visitors based on load average, I guess it can be done with vmods (I guess you'll have to write your own).

share|improve this answer
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.