============================================ Slashdot Effect Prevention Kit version 0.1 "barely alpha" edition ============================================ * INTRODUCTION The Slashdot Effect Prevention Kit (sepk) is a program for Dreamhost PS servers that provides protection against unexpected surges in traffic from sites such as Slashdot or Fark. While the "Slashdot Effect" is not as dreaded as it once was, spikes in traffic can still overwhelm CPU, memory and bandwidth quotas. Sepk started as a fake news story in response to a real-life situation where my site really was hammered by the Slashdot Effect. See: http://humorix.org/articles/1999/03/prevention-kit/ And: http://humorix.org/articles/2001/08/prevention-kit/ Thanks to the Dreamhost API, it's now possible to implement the basic idea for sites using Dreamhost PS. Sepk does two things: 1. Sends a daily (or as often as you like) email report showing your site's recent load average, memory usage, hits, and site referrals. The email includes convenient pre-generated links for increasing or decreasing your Dreamhost PS settings. 2. Monitors your site's load average throughout the day (as often as you like). If the load gets too high, Sepk escalates from Yellow to Red Alert, sending you an email alert about the problem and optionally running a "Panic" script. Sepk runs on your Dreamhost server as a cron job so it can have direct access to server stats and your log files. * REQUIREMENTS The program should work on any Dreamhost PS account. It is written in Perl using only standard modules. * CONFIGURATION Please edit the sepk.cfg file to specify your Dreamhost API credentials. You can also specify when and where the program should send its email reports. You can also specify a "Panic" and "Stop Panic" command. When the program goes to Red Alert (due to an increase in load average), you can have it automatically execute a Panic command or script. It could, for example, turn on more aggressive caching for your website, disable certain portions of your site, or perform some other job to help your site better withstand the Slashdot Effect. You can also define a corresponding "Stop Panic" command to put your site back into regular operation once the load dies down. The panic operation can be anything supported by your shell. Sepk expects to find your access logs in a standard place (~/logs). If that's not the case, or you don't want the system to spend time processing your logs, you can turn this feature off by setting "getrefers" to "no." By default, Sepk considers a load average above 1.0 to be "high" and a sign of a possible Slashdot Effect. Of course, your needs could vary greatly and you can change the "threshold" appropriately. Also keep in mind that if you happen to run a CPU-intensive task (such as another cron job) at the same time, it could throw a false alarm. * OPERATION To manually generate a Sepk report, do: perl sepk.pl report To run the program in normal monitoring mode, do: perl sepk.pl monitor In normal mode, it will adjust the Slashdot Threat Level (Green, Yellow and Red) as appropriate. When it reaches Red Alert for the first time, it will send you an email alert and run the optional Panic script. Ideally, you would launch the program from two cron jobs like this: 50 23 * * * perl sepk.pl report # Send report once daily */20 * * * * perl sepk.pl monitor # Monitor every 20 minutes You'll have to adjust this to specify the location of where you drop the sepk.pl program. Of course you can change the times to your liking. It's better to run the daily report just before midnight so that it can use the hits and referral stats for the whole day. * KNOWN BUGS and LIMITATIONS If your API login has access to multiple PS servers, Sepk will automatically choose the first one from the list and ignore the rest. The numbers of hits and referrals may be off. The idea is to quickly show where traffic is coming and going to help pinpoint problems... this isn't Google Analytics. * TODO LIST The program could easily be modified to test for other things rather than load average. For example, it could keep an eye on the referral logs and immediately panic if hits from Slashdot, Fark, or another enemy website suddenly start to appear. At present the program doesn't automatically adjust your PS quota, although it could easily enough using the Dreamhost API. This seems a little too risky for my taste (and pocketbook), but YMMV. * CONTACT INFO and LEGAL STUFF Sepk was written by James Baughn of www.humorix.org: "Linux World Domination, One Joke at a Time." Email: webmaster@humorix.org The program is licensed under the GNU General Public License 2.0 or later. Slashdot is a registered trademark of somebody. This program is not affiliated with Taco Boy in any way. The author is not responsible for anything bad that could happen, including, but not limited to, server crashes, unexplained increases in your Dreamhost bill, or global thermonuclear war.