Fighting Server Overload

Comment spam is still threatening to shut down our servers. While the Akismet and Bad Behavior plugins keep most of the crap from showing up in the comments, the comment spam still makes it into the database and puts strain on the server. One problem with Askimet, in particular, is that it optimizes the comment tables on average after every 5th comment spam has been deleted. Here’s how the optimization, which causes most of our server load, can be delayed by patching the akismet.php file.

function akismet_delete_old() {
global $wpdb;
$now_gmt = current_time(’mysql’, 1);
$wpdb->query(”DELETE FROM $wpdb->comments WHERE DATE_SUB(’$now_gmt’, INTERVAL 15 DAY) > comment_date_gmt AND comment_approved = ’spam’”);
$n = mt_rand(1, 200); # This used to be $n = mt_rand(1, 5);
if ( $n == 100 ) # This used to be 5
$wpdb->query(”OPTIMIZE TABLE $wpdb->comments”);
}

As an additional anti-spam measure, we added an image plugin. It should work with or without cookies enabled. If you have difficulties posting or commenting, please send us an email.

Technorati Tags:

License

This work is published under a Creative Commons Attribution-Noncommercial 2.5 License.


One Response to “Fighting Server Overload”  

  1. 1 Hanno Kaiser

    Please let me know if the image plugin works.

Leave a Reply


*
To prove you're a person (not a spam script), type the security word shown in the picture.
Anti-Spam Image