cherokee / webserver

Cherokee Web Server
GNU General Public License v2.0
562 stars 105 forks source link

RFE: Time slices per rule #622

Open danielniccoli opened 11 years ago

danielniccoli commented 11 years ago

Original author: pubcrawl...@gmail.com (January 08, 2010 23:03:32)

This is a Request for New Feature in Cherokee.

Simply it is to provide a new rule value for TIME RANGE. A rule could thereby be valid only during the specified time range.

One might use this to automatically direct inbound traffic elsewhere during regular maintenance. So from 3AM-4AM redirect the inbound traffic to a static file Cherokee serves directly instead of reverse proxied cluster with dynamic application server.

Or, someone in could use this to direct traffic to a remote cluster during peak energy cost times. So from 8AM-8PM a local cluster powers offline and Cherokee only remains and the rule gets data from a remote cluster where power is cheaper.

Similarly, I could envision someone using this with outsourced things like Amazon's S3 - utilizing S3 during peak hours but serving the items directly during non-peak.

Original issue: http://code.google.com/p/cherokee/issues/detail?id=707

danielniccoli commented 11 years ago

From ste...@konink.de on January 08, 2010 23:16:25 Would a simple 1 rule from/to be enough or do you want something like advanced matching in the rule itself?

danielniccoli commented 11 years ago

From pubcrawl...@gmail.com on January 08, 2010 23:21:39 A simple rule from/to should be enough...

The only other complexity I could see perhaps would be the addition of week of day also.

So this rule is for Monday-Friday from 3AM-5AM.

Here is another rule that runs on Saturdays from 3AM-3:30AM...

Hope that makes sense. This would make the pulldown and redirection of traffic happen automagically :) Currently, in order to do things like this I have to go into Cherokee-Admin and manually do this. It's prone to user error and much better done by a machine.

danielniccoli commented 11 years ago

From ste...@konink.de on January 08, 2010 23:23:27 The last thing you can solve with an AND function of two rules.

danielniccoli commented 11 years ago

From pubcrawl...@gmail.com on January 08, 2010 23:33:07 Sounds good. If you build it we'll get the second part figured out :)

I need to think of some other reasons why someone would need this functionality. I have several immediate uses for this now- mainly when our MySQL server runs a backup and lags and when we perform some heavy operations on the data.

Electric costs are one big new thing for us in the States. The Time of Day metering is taking off here in the states as more government money is allocated for Smart Grid infrastructure. To consumers, the result of TOD is higher bills and/or scheduling your peak usage in part around the non peak times with lower rates.

Here's a snipet from WikiPedia on Time of Day electric metering: "...TOD metering normally splits rates into two segments, peak and off-peak, with peak typically occurring during the day (non-holiday days only), such as from 1 pm to 9 pm Monday through Friday during the summer and from 6:30 am to 12 noon and 5 pm to 9 pm during the winter. The times of peak demand/cost will vary in different markets around the world...."

Hope that all makes sense and shows some validity in this request. It should give Cherokee another advantage over other web servers by allowing this flexibility in easy to administer way.

danielniccoli commented 11 years ago

From alobbs on January 12, 2010 09:53:35 Sounds good, I do like the idea. +1.

I'd support multiple time slices per rule though. Since other rules do that (extensions, bind, etc) it'd fit better with the general server behavior.