There are so many situations when the web hosting scenario of your blog or website can crash completely. You get a huge traffic spike, mess up your WordPress theme, a whole bunch of people hotlink your images/ static files and your blog is stressed out.
If you have hosted your blog or website on a shared hosting server and have problems regarding heavy bandwidth usages, increased memory consumption amongst other things, you might want to read my experience and how I survived a hosting outrage.
What Went Wrong with my Earlier hosting company?
My site was going fine until one day I received an email from my hosting provider that my site is consuming a large amount of memory on the shared server and I should take immediate action or else my hosting account would be suspended temporarily.
At that time, my site was hosted with Doreo, and the plan was a shared hosting plan(Sh-A). I have been a loyal customer of Doreo for the last two years and never had any problems regarding memory usage, heavy bandwidth and similar problems.
I installed W3 Total cache plugin on my blog, which is by far one of the best caching plugins recommended for high traffic sites. There are two advantages of using a caching plugin, in case you’re using WordPress as the content management system.
First, the plugin creates a cached copy of the older posts and serves the cached copy to visitors requesting the different pages of your site. Since a cached page (static file) is being served to the visitor, you are actually putting less load on the server as far as database queries, calls, function execution are concerned.
The second advantage is that enabling caching on your blog lowers down the overall loading time of your blog to a great extent.
Coming back to my situation, after I installed a caching plugin – my hosting provider emailed me that I should disable the caching plugin immediately because the plugin is putting a huge load on the shared server. Actually, the plugin started generating cached files for all the pages of my site and since my site already had high memory usage issues, enabling the caching plugin increased it even further.
Lesson Learned #1: First fix the problem at hand, then go looking for optimizations.
I disabled the caching plugin, logged in to Cpanel and started checking the logs to find out the current bandwidth status of my hosting account. To my surprise, I found the following details:
Jaw dropped – close to 120 Gigs of bandwidth usage is abnormally high. Moreover, if this trend continues, my site would go down after a couple of days (total bandwidth quota would be consumed completely).
I found the above stat on 24th January and since my hosting quota was almost full, I had to do something about it. There were two options:
- Either upgrade to a different hosting plan at the same hosting provider
- Migrate my entire website to a different hosting provider who offer more bandwidth with the same pricing.
Fixing the abnormal bandwidth usage can be done later, first I needed to make sure that my site does not goes down because the bandwidth quota is full.
Moved Site To Another Hosting Provider – NameCheap.com
I backed up the database, downloaded all the files and moved the entire site to Namecheap.com shared servers(under the business plan). They offered 2K gigs of bandwidth every month (large quota) which would give me enough time to fix high memory usages and heavy bandwidth consumption on my site.
Everything went normal for the first 15 days, i digged into the logs of the earlier hosting provider and found out the following details:
At this time, my site had only 1500 posts and I had hosted all the images and static files (CSS, Theme files, JS, scripts) in a subdomain. This is because hosting static files and images in a subdomain can result in faster loading, since the browser can render parallel downloads from upto 4 different domains simultaneously.
As it turns out, the subdomain was consuming most of the bandwidth. 72 Gigs - no way, something must be wrong here !
While I was trying to fix the problem, came another disaster – Namecheap.com suspended my account without any prior warning !
Lesson Learned #2: When the situation is critical, disable all plugins one by one and troubleshoot the problem. If possible switch to the default WordPress theme for one day and compare the resource consumption and Bandwidth usage from Awstats logs in Cpanel.
I contacted Namecheap support and got my account unsuspended. Till now, I had no idea what the heck is causing such a huge amount of bandwidth and resource usage on the subdomain.
When Disaster Comes, They Come With An Army
After getting my account unsuspended, came another trouble. Namecheap.com put a permanent ban on my account saying the following:
We have reinstated your account two times for high CPU usages. Since, you’re not fixing the problem at your end, you have to upgrade or else we won’t resume your hosting account, currently on the shared hosting plan.
Which means, I had to force upgrade to a VPS plan. If I don’t upgrade, the company won’t reinstate my account and I would lose all the files and the database.
Followed A Forced Upgrade To VPS
I had no other option than to upgrade to their VPS plan and get my site up and running. Upgrading to VPS solved one problem – it bought me a good amount of memory and time, so I can perform tests on my side and reduce the memory load.
After two weeks of continuous tests, trial and errors I found the following:
1. One of the plugins called SimpleTags was a major culprit. I installed the Debug Queries WordPress plugin and found that the Simple Tags plugin was causing a huge number of queries in every other page of the site. See screenshot below:
2. I ran a check in the Database and found that although SimpleTags plugin was disabled, there were more than a thousand redundant entires lying in the database tables.
Lesson Learned #3: Always clean up your database and remove unnecessary tables, values and options. Perform this periodic cleanup time to time, like once in every 3 months.
To fix this issue, I installed the clean options WordPress plugin and deleted all the option values of Simpletags from the Database.
3. After rigorous checking in Awstats logs, I found that there is an unusual script being viewed a good number of times.
I had no idea when I uploaded that script, but this script created thumbnails of all images across that site under a “cache” folder. I downloaded the cache folder to find more than 3000 images and thumbnails being created randomly. I checked the Archives.php file of my theme and found the culprit script being called from the Loop.
Lesson learned #4: Check your codes throughly, check each and every file of your theme and not just the index page or single.php file.
Final Disaster: VPS Panel Locked Because of CGI Scripts
While I was fixing my Wordpres installation, plugin setups and removing the bad codes from my theme, in comes the final disaster. Namecheap.com suspended my VPS account stating the following:
The reason stated in the email is that my server sent a lot of spam emails and the company had to suspend my account to prevent spam abuse.
This is purely abnormal, I mean…come on ! Why would I send spam emails to unknown people when my own website is having server side problems. I repeatedly emailed their support team but could not fix the problem.
One of their support staff told me that I was hosting CGI scripts on my website which was used to send spam emails. I started investigating and found that the CGI script they are referring is nothing but a simple contact form.
Lesson learned #5: Always research the reputation of a hosting company before hosting your website with them. It doesn’t matter how lucrative their pricing plans are, if the main purpose fails in the first place, you’re going to screw everything up in the loner run.
I called Harsh Agarwal over phone and told him about the problem I was facing. He told me that not all hosting providers are optimized for WordPress, and you should ensure that your current hosting provider can handle a medium traffic website easily. If the hosting provider is fairly new and not optimized for WordPress, it doesn’t matter which plan you’re using.
Lesson learned #6: Always ask support from fellow bloggers first and Google later.
Finally, I backed up everything from the Namecheap servers and moved to Hostgator servers from over a month and there has been no problems as such.. I have been serving my website from the
What You Should Do To prevent Hosting Outrages On Your Site ?
- First and foremost, check your theme thoroughly. Check those functions, calls , queries and remove the codes you don’t need at all. Remember that a simple piece of code can put a good load on the server at a later point of time so you should remove all the unnecessary queries and function calls mercilessly.
- Remove the plugins you don’t need and don;t forget to delete the tables from the database as well. Your SQL database is the heart and soul of your website and letting expired options and redundant values in the tables is not at all good.
- Optimize your site’s database and reduce it’s file size, perform this check at least once a month.
- Install a caching plugin like W3 total cache. Do not ignore this because sudden traffic spikes may occur any day.
Also remember to test and troubleshoot the problem yourself and do not completely rely on the support staff of the hosting provider. At the end of the day, it’s your knowledge, experience and understanding which will help you solve and fix the problem at hand.
- Check out: Best WordPress Hosting