2

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

Amandasaurus
  • 30,211
  • 62
  • 184
  • 246

2 Answers2

0

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

GeoSword
  • 1,647
  • 12
  • 16
0

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