Finding out what site is causing server load

apachetop is a great tool that can help identify spikes in loads in your log files. It can show you easily if a particular page on a website is getting large amounts of traffic, or if a certain IP address is hitting your server particularly hard. Checking things like Google Analytics real time may not show you the cause due to the fact that it doesn’t count traffic from Robots. If you have multiple websites on a server you may not want to go through them all and do tail -f to the access or error logs.

apachetop

apachetop in action

This evening in my search to see what was causing the latest traffic spike, I came across this article which showed a great way to check all domains on a Plesk server at the same time.

So I was able to see what was sending 40+ requests a second & block them via my firewall. Of course I checked to see if it was legitimate traffic.

To install apachettop

to install apachettop you can do it via

  • yum install apachetop
  • sudo apt-get install apachetop

Block bad IP addresses

to block via .htaccess file you could do something like
RewriteCond %{REMOTE_HOST} ^37\.59\.71 [OR] RewriteCond %{REMOTE_HOST} ^188\.165\.13
RewriteRule ^(.*)$ http://www.fuckoff.com/$1 [R=301,L]

which would lock all IP addresses starting with 37.59.71 or 188.165.13 and send them to the domain fuckoff.com. You should probably send them to a domain that doesn’t actually exist, so not to overly burden another website with your unwanted traffic.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.