Site running slow, how to find the culprit?

Hello,

My website (onefunnyjoke.com) is running slow lately when it receives high traffic, it even went offline sometimes (clouldfare error 522 or 524). My site was able to handle traffic more than this, but a recent website refresh seemed to weaken the website.

I upsized my linode from 1GB to 2GB, but no luck. I installed "htop" with my very little back-end knowledge, and I am seeing lots of processes using around 50% CPU under "user/sbin/apache2", and the user is mostly "www-data". However, I could not further understand the meaning behind this. How can I find the culprit, for example, which script or function is slowing down the site?

If needed, I reconfigured my PHP with "memory_limit = 256M", and for Appache:

StartServers 4
MinSpareServers 12
MaxSpareServers 24
MaxClients 20
MaxRequestsPerChild 6000

However, with the same settings, the site performed better before the website refresh.

I am one single front-end developer who is trying to manage a website with heavy traffic. Any comments would be greatly appreciated!

Allen

21 Replies

allenwhsu,

What do you mean by when you say "a recent website refresh"? What did you update? WP? Plugins? Both? Something else?

What does your RAM usage look like? What do you get when you run 'free -m' from the command line (without the quotes).

MSJ

Sorry James, a lot happened since this post. My site is down now, once I get it back I will provide all the information.

Thanks,

Allen

OK…It's back now. It was down because the lack of disk space, causing it somehow emptied files when I tried to do some updates. What a fun way to start a year.

A recent website refresh (did not install any new plugins):

1. Based on the "Wordpress Popular Posts" Plugin that I have been using for a long time, I added one more list of popular posts (6) at the bottom of each post. Not sure if doubles the burden for the site.

2. Added 2 more random posts in sidebar in each post (no plugin used).

3. Changed a list of recent posts in a carousel to a list of random posts, all pages (no plugin used).

4. Added a mailchimp newsletter signup form, all pages (no plugin used).

5. Added one more Google adsense ad in each post (no plugin used).

6. Other font size, image size changes in CSS.

This is what I got from 'free -m':

             total       used       free     shared    buffers     cached
Mem:          1491       1371        119          0         36        501
-/+ buffers/cache:        834        657
Swap:          255          0        255

(very little traffic now after the downtime)

Not sure if this help…Again, as a one man team handling a site that probably requires a team of developers, I really appreciate your help.

Allen

Allen,

Your site seems to be working fine at the moment. Are you still having problems with it?

MSJ

Thanks for getting back to me.

I can tell the problem still reminds. It is taking long time to load pages when the traffic gets a bit heavy. I disabled #1 and #3 (from my previous post), but no luck.

I have to work tomorrow, but if you have any suggestions, please let me know. I will further investigate this issue.

Thanks so much,

Allen

Allen,

Are you using a WordPress cache module? If not you should try one.

Have you taken a look at your Longview history? The 30 minute snapshot should be helpful if you are seeing this problem in real time.

Also htop & iotop are very helpful tool to determine what may be using your system resources. If you don't have htop or iotop you can install them with:

apt-get install htop
apt-get install iotop

MSJ

Yes, I am using a cache plugin.

Longview history: It requires me to install things on my server. I will wait until I have more time, just in case anything goes wrong. However, I checked Google Analytics' server response time, it gave me more clue on when might be the point everything goes down. I made some updates and hopefully it helps (site is still very slow now, but I am blaming on caches).

I have tried htop and iotop, and I did see huge CPU and disk usage, but the result is beyond my knowledge. All I know is it has something to do with Apache.

The site is still either slow or give you a timeout error.

I captured a screenshots of htop and iotop results. Although I can't understand, results in htop look like hell to me. If anyone can help me understand the data, that would be extremely helpful.

~~![](<URL url=)https://dl.dropboxusercontent.com/u/192 … odeCom.jpg">https://dl.dropboxusercontent.com/u/19210537/linodeCom.jpg" />

Allen~~

Total guesswork but apache's mod_rewrite can use lots of CPU.

Set the site to default permalinks and comment out mod_rewrite. That may reduce the CPU usage but you loose the pretty permalinks.

This might be useful:

http://www.howtogeek.com/howto/ubuntu/m … apachetop/">http://www.howtogeek.com/howto/ubuntu/monitor-your-website-in-real-time-with-apachetop/

Thanks you guys. My site have been using "pretty permalinks" for years, so I am excluding this as a culprit for now.

I have installed Longview, and I am seeing:

Name ▲    User    Max #   Avg IO  Avg CPU Avg Mem
▸apache2    www-data    20  217 KB/s    605%    762 MB

I know this is a long shot, but can any one tell me that this apache2 could possibly be?

Allen

The apache2 processes are your web server processes.

Have you contacted support and asked them if they have any insight to this?

@Main Street James:

The apache2 processes are your web server processes.

Have you contacted support and asked them if they have any insight to this?

I wonder if apachetop might help him.

I would do some Apache log analysis. Look for a URL that is being hit repeatedly or and IP address or addresses that are hitting the site repeatedly to start with. Something is making your Apache/PHP stack work really hard.

robert

Hi guys,

I apologize for not being able to reply. It has been crazy the past 2 weeks, but now the problem is finally resolved.

I contacted Linode Support, they moved my site to another host, cause it seemed to have some great amount of CPU steals. The problem reminded, so they moved it again. After the 2nd move, My site is finally back to normal (about 1-2 hours after the migration).

However, I was doing crazy updates (wanted to find out what the problem was) during the whole process, so to be honest, I can't tell what fixed it. Maybe both.

Anyway, thank you guys for your great great help. I really appreciate it.

Thanks!

Allen

CPU steal is probably not the root of your cause. You may experience this problem again, going for a server migration with linode is not the best solution.

If your kjournal is constantly high you might want to check what is being written to disk (maybe cached files)? This can cause a big IO bottleneck and seriously slow down your site.

@livefree:

CPU steal is probably not the root of your cause. You may experience this problem again, going for a server migration with linode is not the best solution.

If your kjournal is constantly high you might want to check what is being written to disk (maybe cached files)? This can cause a big IO bottleneck and seriously slow down your site.

A server migration worked for me once too, must have been someone's VM hogging the system it was on.

Not really helpful, but we find Wordpress uses a lot of resources so don't use it. The few WP sites we have adopted use far more resources than other non-Wordpress sites. These sites have the cache plugins recommended, but still slow and resource intensive. So we just dont bother using Wordpress for our customers. Of course, if you are not a web developer then its a great system to get online and manage it yourself, but with that ease of install/use/plugins will come other negative factors.

@livefree:

CPU steal is probably not the root of your cause. You may experience this problem again, going for a server migration with linode is not the best solution.

If your kjournal is constantly high you might want to check what is being written to disk (maybe cached files)? This can cause a big IO bottleneck and seriously slow down your site.

Yep, it still happens when the traffic is high. I keep seeing high CPU steal as well…which almost looks like another migration is needed? It's very frustrating to see the site went offline when the site just went viral. While I am still trying to fix it, are there any firms that would optimize your site for you? I googled some keywords but only ended up with some spammy websites.

Allen, I can refer you to a person who helped me with some work. I found him to be professional, reliable, and competent. Just let me know if I should reach out to him to see if he is available to do the job. I do wonder though if your site is just too popular for the current configuration.

@yaz:

Allen, I can refer you to a person who helped me with some work. I found him to be professional, reliable, and competent. Just let me know if I should reach out to him to see if he is available to do the job. I do wonder though if your site is just too popular for the current configuration.
Hi Yaz,

Thank you. I contacted Linode Support and did another two migrations (first one made things worse, still waiting to see the performance after the 2nd migration). I will keep this in mind and will let you know if I need help.

Thanks!

Allem

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct