High-load Website (WordPress) Optimization : IlmuKomputer.com

Mr. Romi, founder of IlmuKomputer.com (IKC), yesterday asked me to help optimize this website. A bit about IlmuKomputer.com, it means “Computer Knowledge”, and contains a lot (and I mean it) free high quality computer tutorials.
As you can easily guess, the website is very popular. On peak hours, it’ll usually become overloaded, and will become unresponsive.

I’m only too happy if I can be of assistance to IKC’s team in their good cause. So I started working on it with help from one of my staff, Yopi.

Turned out that what we’ll be doing will be very different with what most others do. Anyway, IKC is a very popular website (and “slashdotted” daily, by leechers), so what works for most others doesn’t work for us.

The Bottlenecks

A bit of background – IKC uses WordPress as its CMS. It’s a very nice CMS, and makes your life easier. I’ve used WP myself since version 1.5.x. However, being database-based, there are a lot of points within its a WP-based infrastructure which can become a potential bottleneck. So if your website started to become popular with this CMS, you will need to start optimizing it.

After examining the situation for a while, it’s clear that MySQL was THE bottleneck. Output of top shows it using at least 8 times of CPU time than other service. Mr. Romi also told me how it kept on falling down on peak time.

Apache (and PHP, since it’s compiled as Apache module) is the next one; with each of its process using more than 10 MB of RAM. This may seem insignificant at first, but multiply that by (potentially) 150 processes – and you’ve got quite a memory hogger here.
Also CPU-usage wise; I’m quite surprised to see that each incoming request will cause the particular process’s CPU usage to spike to more than 50%.

Initial actions

I asked Mr. Romi to increase the size of MySQL’s internal cache size. He did, but the machine still fell down in daily basis.

He has also implemented caching on the app server (PHP) by way of wp-cache plugin. Still no joy too.

The Edge

I decided that we need to go straight to the “edge”, and stop the load there.

I proposed that I setup Squid in HTTP Acceleration mode. This way, most of the requests won’t even touch Apache, much less MySQL. Squid will bear most of the load, but since it’s very efficient, it should be able help a lot in making the website perform better.

Since I’ve got a few things to do myself, I asked Yopi to setup Squid in our test machine.
I just gave him pointers now and then, yet he managed to finish testing the setup and implement it in IKC’s server in just about 3.5 hours.

Then I showed him “tail -f /log/squid/access.log”, and we watched in amazement on how quickly the TCP_MISS lines are changing to TCP_HITs.
After about 12 hours, I increased the cache_mem size, and the TCP_HITs are slowly changing to TCP_MEM_HITs.

The result

Squid is working as we expected.

Average server load dropped from 30% plus to about 3%. While squid’s CPU usage increased from 0% to an average of only 2%. A very nice trade off.

After about a month, I checked the website’s logfiles, and saw some very nice numbers — traffic to IlmuKomputer.com has doubled ! Needless to say, Mr. Romi is very happy with it.

I also found that everyday there will be people downloading the contents using crawler software – such as Teleport Pro, wget, etc. I asked Mr. Romi if he’s got problem with it, and he says no. It is his mission to spread knowledge for free after all. So I let these leechers alone.

Come to think of it, it’s possible that these crawlers are the ones causing IKC server to fell down at peak hours. Example, Teleport Pro is able to download 10 links simultaneously at the same time. Then once any of it is finished, it will instantly start download the next one. When all 10 downloads access the database, and many crawlers at the same time, not many servers will be able to stand up to it. It’s like being machine gunned wearing just a simple leather cloth. If you have had the experience of having your website linked from Slashdot or Digg, you’ll understand what I’m talking about.

In this case, squid acted as a thick titanium armor, and taking most of the hits for your server. I suspect now the number of crawlers has increased than before, but it shouldn’t be a problem.

MySQL is a bit strange though. Sometimes its CPU usage can be as high as 160%. Thankfully this is very rare, so it’s probably just some internal clean-up routine.

One day, after happily watching the low load on the server for a while, suddenly everything froze. Even my SSH connection. Attempts to reconnect to the server failed.
After a while, I was finally able to connect again. Looking around, I noticed there’s some sort of bandwidth limiter daemon running on the server. After consulting with Mr. Romi, I killed it. The problem stopped.

Happy ending ?

I’m still monitoring the server as we speak for glitches. For example, squid seem to hang from time to time. This can be caused by anything from bad memory to problem with specific hardware configuration; so for now I’ve setup a cronjob which will restart it in certain intervals.
It seems to help, so I can troubleshoot the problem in peace.

Anyway, I’m sure that with the increased availability, even more people will visit the website (Ed: confirmed!). Then at some time in the future, we may find the server overloaded again.

In that case, there are still many things which we can do to keep IKC up & running in just one server :

  • Coral-ize internal links : Coral is a global cache with servers all over the world. It has proven to help people with overloaded servers to lighten their load (when slashdotted, digged, etc). With the Coralize plugin, all of your internal links will point to its Coral cache.

    Actually, for most people, this may be the easiest and the best step they can do. I can setup Squid because IKC has its own dedicated server. Not everyone does, I personally also own a (shared) webhosting account. Coral CDN (Content Distribution Network) is a very nice & easy solution to us. It’s rarely mentioned though, so here you go.

    If you’re not using WordPress, you can still utilize Coral CDN easily ! Just append .nyud.net:8080 to your links. For example, if you access http://harry.sufehmi.com.nyud.net:8080, you’ll actually access a Coral server, serving a copy of my website from its cache.
    I did say that it’s very easy, didn’t I ? 🙂

  • RAM Upgrade : This will enable Squid to have bigger memory cache size, therefore increasing its effectiveness significantly.
  • Roundrobin Edge servers : If the load is so high that even Squid is overwhelmed by it, then we can implement a cluster of Edge servers. People can volunteer their servers and have it act as the edge server for IlmuKomputer.com.

    The incoming requests are spread over the edge servers by way of Roundrobin DNS feature. It’s not the best way to do it, but it’s very easy and the cost is almost nothing.

  • Use lighttpd : Apache is a rather heavy webserver. I personally like its (amazing) flexibility (there’s a reason why it’s called the Swiss Army Knife of Webserver), but at times you’ll need something else. From my experience, lighttpd + fastcgi is very nice alternative to Apache + PHP. The features are now quite similar to Apache’s, but it’s much more lightweight. Its community is also quite helpful and happy to help a newbie within reasons. Recommended.
  • And many other ways

Last, we’d like to say thanks to Mr. Romi for giving us the opportunity, it was very interesting ! Hope IKC will become even more successful in the future, therefore benefitting even more people. Well done pak.

198 thoughts on “High-load Website (WordPress) Optimization : IlmuKomputer.com

  1. Hmmm,

    I’ve been outside of web programming and optimization for quite a while, but I’d say using cache would be effective in this case. Either hard cache (generate the pages) or just cache it in the RAM. So you don’t need big traffic to MySQL. What I see needed to update is the page statistic (“Halaman ini dibaca x kali”), and this can be accomplished using ajax. So the page content is grabbed from cache, and the statistic is updated separately using ajax.

    If the code is complex then the op-code cache helps alot. I remember there were some op-code cache for PHP out there, but don’t know whether they are still in development or not, namely turkmmcache, apc, etc.

    How’s that sound?

  2. One more thing, downloadable files should be separated from the main server. Using small web server like thttpd would help a lot.

  3. Hi all, thanks for the suggestions. A bit more info, Pak Romi has tried eacclerator, but it doesn’t seem to work.
    At the moment, Squid is also caching downloadable files, so most of the downloads at the moment are from squid (not apache).
    .
    Anyway, Apache’s performance was so bad, I decided to skip optimizing it altogether, and just try to stop as much traffic as possible from reaching it.
    .
    Now that the server has stopped falling down, then I can start looking to optimize Apache. However, this may not be possible because it’s tied to CPanel.
    We may have to compile Apache ourselves to make it fully optimized.
    .
    For the time being though, Squid is holding up very well on its own. This gives us ample time to experiment with other solutions.

  4. Waduh, pake bahasa Inggris neh, Tapi yang bahasa Indonesia di blognya mas Romi Satriyo aku udah tahu kok

  5. @harry: well, it’s implemented to our intranet server for about 2 years ago till now.

    It’s only PIII 700Mhz, with SDRAM 128, using minimal CentOS and served about 200 pc all day. Thx to squid for optimizing my server 🙂

    anyway, have you optimized your apache? it could be optimized on httpd.conf

    @saya: mr. mdamt, thx a lot for your tricks.

  6. Thanks banget om Harry, sudah nolongin dan langsung turun tangan 🙂 Seminggu ke depan ini kita coba dulu lihat kondisi. Aku server cukup stabil dan kondisi CPU dan Memory terjaga. Paling tidak untuk sementara sudah lumayan, sampai kita pikirkan lagi strategi lain. Sekali lagi, thanks.

  7. Really nice.., but i still wondering, is WP strong to be used as a portal CMS.. I’ve wrote my doubt about this on my web..

  8. wordpress, php, and squid – they don’t work along well 🙂
    .
    Here’s an excerpt from a report made for one of my client :
    .

    Wordpress & PHP, however, produces HTTP header which basically instructed Squid not to cache. We need to change this :

    ### editing /usr/local/lib/php.ini
    was: session.cache_limiter = nocache
    now: session.cache_limiter = public

    ### backed up /home/myblog/wp-includes/classes.php to /home/myblog/wp-includes/classes.php-original
    ### editing /home/myblog/wp-includes/classes.php, line 178
    ### WordPress version 2.3.1
    was: nocache_headers();
    now: //nocache_headers();

    .
    Now their website can handle hundreds of requests per second without breaking a sweat.
    .
    Hope it helps someone.

  9. A very nice article for the WordPress Comunity. Implementation like you said on the squid +Php and mysql with the Appache make wonders.

    Thanks for this Tip

  10. @Dolly – problem is, on very high-load, even the Apache itself become the bottleneck.
    .
    Then the request will be passed by (already over-loaded) Apache to PHP.
    .
    Do you think memcached will be able to be of any use in this kind of scenario ?
    .
    About Lucene, it’s a great search engine. But, again, we need to understand our requirements first, and then use only the appropriate tools.
    .
    Sometimes, just using Google searchbox can be enough already.
    .
    Hope it explains it.

  11. @sufehmi
    sorry, I think the bottleneck is MySQL only. So I suggest to use memcached for cache and use lucene to search. Its can reduce the MySQL load.

  12. Hi Dolly, truth to be told – Apache/PHP is not very scalable. In many cases, they can only serve about 2 – 5 requests per second.
    .
    This is still way better than others, for example, Ruby. But still, when your website are very popular and got bogged down by PHP, you need a solution.
    .
    So yes, we need to first find out where the bottleneck is. Only then we can find the right solution.
    .
    In your case (overloaded MySQL), I think indeed memcached can be of help.
    .
    Thanks.

  13. Hi There,

    Just came by your site searching for more infomation about web traffic info, and I found some great info here 🙂

    I`m working on building the best! Viral Traffic site now so I do a lot of reviews all over the net.

    Have A Great Day.
    Regards,
    Jack L
    Viral Traffic Center.com

  14. Hi There,

    Apache isn’t as bad you think. The performance of Apache 2.2 is excellent its super scalable thanks to enhanced multithreading and non-blocking IO support. A friend of mine switched a high traffic tech blog running Litespeed + LSAPI + XCache to a carefully configured Apache 2.2 + FastCGI + XCache and surprisingly, the performance is on par!

    Before runing litespeed, the site ran on Apache 1.3 and died every now and then. Btw the server is a dual harpertown with 8GB of RAM.

  15. Nice article. Yeah, I’ve had a few issues with WordPress on a few high traffic sites, especially sites I had a lot of plugins on. So, if you’re running on a shared host, optimization is really important.

  16. Wow…what a long article. I agree with the above comment the “catch” is the point. Thank you for your article.

  17. Hello!

    I have used a plugin before, and it converts all the wp pages on the fly to html, and that way the server load is DRASTICALLY lower, I have looked for the plugin, but don’t remember the name, i’ll check at my home laptop because that is where I have the login details for that blog!

  18. Hi. I want to say to you somethings about optimization. Optimization or optimality is a term that may refer to:
    Optimization (mathematics), trying to find maxima and minima of a functionOptimization (computer science), improving a system to reduce runtime, bandwidth, memory requirements, or other property of a system; in particularCompiler optimization, improving the performance or efficiency of compiled codeSearch engine optimization, in internet marketing, methodologies aimed at improving the ranking of a website in search engine listingsProcess optimization, in business and engineering, methodologies for improving the efficiency of a production processProduct

  19. Thanks for writing about this, these tips are very interesting! I hope I need to use them someday! That would mean my website has a LOT of traffic! Hehe

  20. Nice posted! But I am running on a shared host, So somebody suggested optimization is really important. why is so? If its just like improving a system to reduce runtime, bandwidth, memory requirements, or other property of a system. Well I agree but to get the Traffic do there is not any other method?

    I even agree with efficiency of production, but let you know ever phase is not same all time. so more than efficiency an consistence is important. LOT of traffic come surely……!

  21. Thanks for this. It’s a really steep learning curve for me. Recently lost job and trying to make a living online. All these articles are really useful. There seems to be a lot of crap out there. Thanks for something useful for a change

  22. Squid is the man!!

    I think it is the best proxy. With squid you can improve your response times because it caches and reuses frequently-requested web pages. While squid is answering the request your web server will be happier and your MySQL even more happier. That’s why you see such great performance improvement.

    I’m happy you managed to fix it. Nice blog BTW. And thanks for allow me to post in your blog.

  23. This blog Is very informative , I am really pleased to post my comment on this blog . It helped me with ocean of knowledge so I really belive you will do much better in the future . Good job web master .

  24. What a great resource this post is! I’ve noticed a real slowdown with two of my wp sites, so I’m going to go through these potential solutions one by one and see if I can nail it down. Cheers!

  25. hello there!

    I am looking around and planning to update my website to WordPress-based website. My website has about 250 to 300 unique visitors a day. These think I have to be worried about the loads on the server?

    Thank you for your time

  26. 300 unique visitors should be fine. No optimizations should be needed.
    .
    However, I’ve seen themes & plugins which put insane load on the system. For example, I’ve encountered a theme that will put 5x extra load. The system fell over the instant I put it on.
    .
    Other than that, you should be alright.

  27. Moving to 64-bit does not always give an instant speed boost.
    .
    Sometimes it’ll actually cause problems, because many 64-bit software are still new, and not really as rigoriously tested as its 32-bit version.
    .
    So moving to 64-bit software should be executed cautiously, to avoid causing problems, and to ensure maximum benefit from this move.

  28. I am looking around and planning to update my website to WordPress-based website. My website has about 250 to 300 unique visitors a day. These think I have to be worried about the loads on the server?

  29. Super article.

    Gives great insight into the different ways to approach optimisation …. and thanks too for the followup posters.

    Made for a really interesting read.

  30. @free music videos – You should be okay there.
    .
    Just make sure to avoid plugins / themes that will put crazy load to the database.

  31. Hi m8,

    thanks for your blog. I searched another things but found your blog. So thanks for your work!!!

    Best wishes from a still reader from belgium :-]

  32. From experience, I agree, that by moving to a 64-bit CPU increase your speed and can cause the system to faulter as most of the softwares built are tested on 32 bits.

  33. Hi, thanks for share this information.
    I would like to ask your advice about using WordPress for our news portal site. Is it suggested or must be avoid. Any idea?

  34. thank you for this nice info, but after implementing several optimization (cache for wp, mysql and apache) for my blog, I’ve seen that performance decrease. I wonder how to fix that?

  35. @gosip – if you allocate **too much** memory for the cache, then it will rob memory from other software which needs it too.
    .
    The caches must be rightly sized – so it will provide performance boost, without causing the server as a whole to slowdown instead.

  36. @budiwijaya – ada caranya, tapi tidak ada customer saya yang memintanya. Karena mereka semua menggunakan Google Analytics – yang tetap bisa berfungsi normal walaupun menggunakan cache / squid.

  37. This is a helpful article for wordpress users!
    Thanks for the tip! Hope you could post more updates how your server’s doing

  38. informative , I am really pleased to post my comment on this blog . It helped me with ocean of knowledge so I really belive you will do much better in the future . Good job

  39. @pak harry: Ah, terima kasih petunjuknya. Kebetulan akhir2 ini situs tersebut juga udah merangkak naik ke arah 99%. Jadi dalam 1 minggu sempat juga down. Mungkin karena memang di headernya cms belum di optimze.

    Sekali lagi terima kasih. Satu hal tersebut yg terlupakan oleh saya.

    Btw, Selasa besok saya kebetulan di jkt. Malemnya insyaAllah ke Wetiga. Kalo tidak keberatan bisa kopdar disana bareng teman2 wetiga pak?

    –budiw

  40. @budiw – Wah telat saya… mohon maaf pesannya baru terbaca 🙂
    .
    Kebetulan juga sejak kemarin saya sedang demam, beberapa meeting juga saya batalkan.
    .
    Mudah2an nanti kita bisa ketemu ya. Trims.

  41. saat kameralar, gizli kamera çeşitleri, kravat kamera, anahtarlık kamera, duvar saati gizli kamera, kalem kamera, saat kamera çeşitleri

  42. The squid is a good solution. Another solution (and more simple to install) is to use a wordpress cache plugin, which automatically create flat html files to be served to site visitors – in this way the number of MySQL database accesses is drastically reduced.

  43. This blog Is very informative , I am really pleased to post my comment on this blog . It helped me with ocean of knowledge so I really belive you will do much better in the future . Good job web master .

  44. Thank you for the usefultip! I think we can use of memcached for cache and use lucene to search in order to reduce the MySQL load.

  45. As a wordpress user, im delighted to see it is so expandable. As our site grows im glad i will be able to keep wordpress. as i do enjoy using it. Thanks for the post

  46. Wow,great! This article is really excellent! You must see !

    Blu-ray Burner software is a powerful and best video Blu-ray DVD burner and Blue-ray burner tool.It can help you burn videos to Blu-ray Disc (BD) and also enable you to burn all these videos to Blu-ray disc and create your own Blu-ray movie.

  47. if you are using Dedicated Server or VPS, i thing we can reduce load modules by editing httpd.conf file using SSH. So it can be reduce load server

  48. Firefox is getting slower and slower. I’m using Google chrome instead, because I find Firefox slower and it’s affecting my work as a content writer.

  49. Thanks banget om Harry, sudah nolongin dan langsung turun tangan 🙂 Seminggu ke depan ini kita coba dulu lihat kondisi. Aku server cukup stabil dan kondisi CPU dan Memory terjaga. Paling tidak untuk sementara sudah lumayan, sampai kita pikirkan lagi strategi lain. Sekali lagi, thanks.

  50. They said that I have to pay a penalty amounting to 300USD (around Php13,500.00) because they already send my papers for the processing of my Visa..They will not give back my passport if I will not pay the said amount as a penalty..

  51. Turned out that what we’ll be doing will be very different with what most others do. Anyway, IKC is a very popular website (and “slashdotted” daily, by leechers), so what works for most others doesn’t work for us.

  52. Apache (and PHP, since it’s compiled as Apache module) is the next one; with each of its process using more than 10 MB of RAM. This may seem insignificant at first, but multiply that by (potentially) 150 processes – and you’ve got quite a memory hogger here.

  53. I’ve seen themes & plugins which put insane load on the system. For example, I’ve encountered a theme

  54. I have used a plugin before, and it converts all the wp pages on the fly to html, and that way the server load is DRASTICALLY lower, I have looked for the plugin, but don’t remember the name, i’ll check at my home laptop because that is where I have the login details for that blog!

  55. I am very glad to know that your site is upgrading from the ccsp certification with simplest to more faster and synchronized form. I am quite familiar of a lot of sites since I work as a freelance writer and one of the sites that I find evolve is your site respectively. I am looking more on your site progress as well as new version that is more convenient and helpful to the members like me. I really appreciate the move that you made. Thanks a lot!

  56. Klo saya sendiri yg miskin ilmu seo, hight load site pd CMS WP paling tidak dgn cara berikut:
    1. gunakan pluin yg bener2 diperlukan
    2. minimalkan image, klo terpaksa hosting image di tempat lain

  57. Good post. I bet a lot of very large companies use WP for their websites and we don’t even know it. WP has really gotten to be one of the premier ways to launch a quick but clean website. Ya gotta love all the tools that you can get for it.

  58. However, I’ve seen themes & plugins which put insane load on the system. For example, I’ve encountered a theme that will put 5x extra load. The system fell over the instant I put it on.

  59. Great accelleration from mr harry,I’m beginner with computer science,so this is very usefull for me to improve my ability,thanks..

  60. Topiramate Kidney Stones
    Topiramate 25 Mg Tablet
    PDF/Adobe Acrobat – Quick Viewby KL KWONG – 2002 – Related articlesof epilepsy extends far beyond prescription of medication. Psychological, educational and social problems are much more important than the seizures and …hkjpaed.org/pdf/2002;7;169-172.pdf
    Topiramate And Migraine
    Epilepsy is diagnosed when a person has recurring seizures, … want that you can treat epilepsy is to be honest and to take your medications as prescribed. …
    Learn about the prescription medication Topamax (Topiramate), drug uses, dosage, side effects, drug interactions, warnings, reviews and patient labeling. – Cached – Similar
    Compare prices and buy Lamictal, Lamitor and Lamotrigine with no prescription needed. Lamotrigine is used to control partial epileptic seizures in adults.
    Klonopin online a prescription medication that is commonly used to treat Epilepsy and panic disorders. … Epilepsy (Seizure disorders) Panic Disorders …
    PDF/Adobe Acrobat – Quick ViewMen Managing Epilepsy or Seizure Disorder. If your medication is changed… …. Plan to carry extra medication and prescriptions. …www.manitobaepilepsy.org/Men%20Managing%20Epilepsy–Seizure%20Disorder.pdf
    Topiramate Buy
    Topiramate 200 Mg
    Topiramate Without Prescription
    All about Topamax Tablets. View complete and up to date Topamax information – part of the Drugs.com trusted medication database.
    Topiramate 100 Mg
    How Much Does Topiramate Cost
    Epilepsy & My Child Toolkit: A Resource for Parents with a Newly Diagnosed Child – As … between seizure activity and anti-epileptic medication dosages. … about Medicare Prescription Drug Coverage & Health Care Reform, click here. …

  61. they are very usefull informations .Thanks for these tips, they really help get the load down on the server! thanks very much,again.

  62. Hi,

    I`d like to say that you always offer accurate information and I have been an long term reader of your site for quite some time. Just wanted to say thank you really 🙂 for all the good work you do. I am attempting to run my own blog however I think its too general and I would like to focus more on smaller topics.

    Regards,

    Sophie

  63. Epilepsy & My Child Toolkit: A Resource for Parents with a Newly Diagnosed Child – As … between seizure activity and anti-epileptic medication dosages. … about Medicare Prescription Drug Coverage & Health Care Reform, click here.

  64. I just realized about wp problem in high load. i really thanks. this arcticle can explain preventif act.

  65. pilepsy & My Child Toolkit: A Resource for Parents with a Newly Diagnosed Child – As … between seizure activity and anti-epileptic medication dosages. … about Medicare Prescription Drug Coverage & Health Care Reform, click here 650-293 | 1Y0-A21 | 000-108 | 000-968 | 70-664 | MB3-859 |

  66. What a great resource this post! I noticed a real slowdown in two of my WP sites, so I’ll go through these potential solutions, one by one and see if I can nail him. Cheers!

  67. Interesting article. I can say it is a myth that switching to 64 bit can give you boost though it will increase the performance but you will feel that speed.

  68. Thanks for your publication. I also feel that laptop computers have grown to be more and more popular right now, and now are usually the only form of computer employed in a household. The reason being at the same time actually becoming more and more affordable, their computing power is growing to the point where they’re as effective as pc’s from just a few years back.

  69. It is the kind of information I have been trying to find. Thank you for writing this information. It has proved utmost beneficial for me. Go with site instastalker to downlaod free anything you like on instagram.

Leave a Reply

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