Site running slow, how to find the culprit?
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
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
Thanks,
Allen
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
Your site seems to be working fine at the moment. Are you still having problems with it?
MSJ
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
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
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.
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=)
Allen~~
Set the site to default permalinks and comment out mod_rewrite. That may reduce the CPU usage but you loose the pretty permalinks.
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
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.
robert
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
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.
@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.
@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