February 20, 2012

WordPress Bad Behavior

I received an email from my web host Site5 while I was at the cricket on Tuesday, saying this site had been suspended because it was using too many system resources (CPU and memory) for shared hosting.

“Your account is consuming about 10.66% of CPU resources on a shared server, which is not a fair share,” the message said.

“We had no choice but to block the web access of following script to stabilize the server. Because resources are shared, I’m sure you can understand that we need to take action if one site is causing downtime for dozens of other sites.”

I actually don’t fully understand why the site was suspended without warning, but that’s another issue. Being at the cricket I had no way of taking immediate remedial action anyhow.

According to Google Analytics, this site receives about 300 visitors per day, which by itself should not consume excessive server resources.

However, it’s always good to keep the house tidy so I was happy to review and implement several measures.

1) Once at home I installed WP Super Cache. This plugin generates static html files from a dynamic WordPress blog. After a html file is generated, the web server will serve that file instead of processing the comparatively heavier and more expensive WordPress PHP scripts.

As it currently stands, about 24 hours after my site was restored, the cache holds 9.89MB with 13 pages and 124 expired pages.

2) I also installed the WP Smush.it plugin and smushed all my images.

Smush.it uses optimization techniques specific to image format to remove unnecessary bytes from image files. It is a “lossless” tool, which means it optimizes the images without changing their look or visual quality.

It took about an hour to bulk process all my pictures, and I noticed that most were being reduced in size by around 30 percent.

3) I deleted post revisions from the database and optimized the database.

4) I removed the Daily Stats plugin, which may or may not have been adding to server load. It certainly had a hefty database table of 2MB, which I deleted.

5) I removed several inactive plugins.

Bad Behavior plugin

6) Late yesterday I installed the Bad Behavior plugin. I had used this plugin previously, but encountered some problems with it. So far, it’s working okay this time.

Bad Behavior works by screening all requests to block email harvesters and malicious robots.

Bad Behavior analyses the HTTP headers, IP address and other metadata regarding the request to determine if it is spammy or malicious.

In just under 24 hours, Bad Behavior has blocked 839 attempted visits. That seems an extraordinary number and is probably why the system resources are being strained. An example of the log is pictured below.

According to the FAQ: “By preventing spambots and other malicious bots from ever accessing any of your pages, your bandwidth usage and server load will drop significantly. How much depends on how many malicious bots visit your site regularly. It can also help prevent a denial of service where your Web host shuts off your account because spambots were using up all the available resources.”

That’s what I want to achieve, of course, a reduction in use of system resources.

Site5 emailed me again this morning to say there has been an improvement in that regard, down to 6.81 percent, but more needs to be done.

I’m hoping that if Bad Behavior does its job, there will be a more significant reduction in the next couple of days.

If anyone has encountered any difficulty using this site, please let me know.

Bad Behavior log report

Please comment

*

CommentLuv badge