FractalizeR: VBulletin 4 extensive optimization guide (Part I)
by
03 May 2010
Preface Actually, I never bothered to optimize my server for VBulletin, because the server we purchased for forum is really powerful. But once upon a time logwatch told me, that smartd told her, that he found several relocated sectors on one of server HDDs. And then instantly I realized, that many time ago when I assembled that server, I configured HDDs to be in RAID-0 (striped mode) Oh . When you will make some stupid thing on your server, please keep in mind, that there are some people that can do things even more stupid . Nothing critical happened, because I, actually, have all database backups. Database snapshots are made on server using http://www.fractalizer.ru/frpost_429/frpost_356/php-script-to-backup-all-databases/ every hour or so (BTW, database backup on my server of 1.12Gb database (reported at admincp) takes around a minute to complete together with compression). So, we had to visit datacenter and remove/replace HDDs. To allow our forum users to continue using forum until we fix that, we moved our forum to a new server. After forum move, I upgraded it to v4 to benefit from friendly URLs. And there it started. Server load almost immediately reached 4.0 (server had two dualcore CPUs, so this is almost 100% of standard load) and those were even not peak hours. Of course, that was not because of V4 (I turned off both that huge CMS issuing ~200 queries on home page and blogs). This was because that new server where the forum was moved to was less powerful. Of course, 4.0 is not a heavy load for server (once one of my servers reached around 100.0 and still I was able to login by SSH ). But nevertheless, that was the moment, where optimization hysteria first visited my head. I used my Linux knowledge combined with Google power to provide you with this optimization guide. It is concentrated around things, that can be easily and simply applied to your server without too much work. Most of the time it explains basic things, that seem apparent. But I am sure, 90% of beginner administrators never use them altogether. This guide does not pretend to be complete one. To follow most of it, you have to have some basic Linux knowledge and root access to your server. However, many of the described optimizations can be done just with Control Panel administrator and FTP accesses. Please feel free to criticize it and add things to it. If you are going to republish it, I will be most pleased, but please keep my copyright on it and http://www.fractalizer.ru/frpost_429/fractalizer-vbulletin-4-extensive-optimization-guide/ with all improvements and corrections you might send me. This guide mostly provide things, that are safe to your server or could be easily rolled back. However, please keep in mind, that you apply them on your own peril. If
I cannot promise to do all instantly because of the amount of daily job I have, but will do my best. Generic all-good server optimizations This section will list optimizations, that are, actually, good for any forum and any server. Optimize all *.png images in forum folder VBulletin forum images and, especially, addon and style images can be optimized reducing their size up to 50% from original. Install http://optipng.sourceforge.net/ tool (for example, from http://rpmrepo.org/RPMforge repository. If you are on RedHat or CentOS you can install RPMForge repository quickly http://wiki.centos.org/VladislavRastrusny/AutoRPMForgeRepo and install OptiPNG from there using yum install optipng after.) and use it to optimize forum images. On Linux you can just enter forum directory and execute there the following command, after you have optipng rpm installed: find -name "*.png" | xargs optipng This will run optipng command on every *.png image in the directory you are currently in (check that with pwd, it should be forum directory) and below. OptiPNG will use its own default settings this way. They are ok 99% of cases. I leave studying its options to you. If you cant run optipng on server, just download all images and optimize them on your home PC (there is a Windows version of OptiPNG too). But remember to do that again after forum update, because update package may overwrite your optimized images. OptiPNG does not affect the quality of them. At least it is not supposed to, so you have a backup anyway, right? Prevent browser from resize images If you are developing a skin or just make new forum status icons, keep in mind, that you should not make browser resize your images (for example, if your icon on disk is 128×128, png, but you specified in your style, that it is only <img width=48″ height=48″ src= />. This will make an impression on user, that page is loading too slow (browser will be busy resizing all your images and that takes CPU time). Use external YUI It is faster to use YUI from Yahoo or Google servers. You can set which one to use YUI from in VBulletin Options -> Server optimizations -> Use remote YUI. I prefer Google Move your attachments into filesystem Move your attachments into filesystem. Go to your AdminCP, expand the Attachments menu on the left side and click Attachments Storage Type. Move Avatars into filesystem The same as with attachments, you can move avatars into file system. Go to your AdminCP, expand the Avatars menu on the left side and click Avatars Storage Type. Prevent search engine spiders from visiting areas of your forums that they do not need to spider Create a robots.txt file with the following and upload it to your public_html directory: User-agent: * Disallow: /forums/admincp/ Disallow: /forums/clientscript/ Disallow: /forums/cpstyles/ Disallow: /forums/customavatars/ Disallow: /forums/customprofilepics/ Disallow: /forums/images/ Disallow: /forums/modcp/ Disallow: /forums/ajax.php Disallow: /forums/attachment.php Disallow: /forums/calendar.php Disallow: /forums/cron.php Disallow: /forums/editpost.php Disallow: /forums/global.php Disallow: /forums/image.php Disallow: /forums/inlinemod.php Disallow: /forums/joinrequests.php Disallow: /forums/login.php Disallow: /forums/member.php Disallow: /forums/memberlist.php Disallow: /forums/misc.php Disallow: /forums/moderator.php Disallow: /forums/newattachment.php Disallow: /forums/newreply.php Disallow: /forums/newthread.php Disallow: /forums/online.php Disallow: /forums/poll.php Disallow: /forums/postings.php Disallow: /forums/printthread.php Disallow: /forums/private.php Disallow: /forums/profile.php Disallow: /forums/register.php Disallow: /forums/report.php Disallow: /forums/reputation.php Disallow: /forums/search.php Disallow: /forums/sendmessage.php Disallow: /forums/showgroups.php Disallow: /forums/subscription.php Disallow: /forums/threadrate.php Disallow: /forums/usercp.php Disallow: /forums/usernote.php If you use something other than /forums/ for your forums directory, you will want to adjust the paths accordingly (just like /usernote.php if your forum is in www root) Disable File Access Time updates in your filesystem If your forum is running on VDS/VPS or dedicated server, you need to disable updating access times for your filesystem to improve performance. You can do that by adding noatime attribute into your /etc/fstab so that the partition you have forum files on have this option enabled like this for example: Code:
/dev/md2 / ext3 defaults,noatime 1 1 Please note, if you make a mistake in editing fstab, you may end up with non-booting system and you will need to boot Linux into single user mode or startup from emergency disk to repair this file. This is especially dangerous if you have no physical access to your server. Install SPRI SPRI is a small bash script, that runs regularly and adjusts process priorities to distribute system load. You can get it http://www.rfxn.com/projects/system-priority/. Sometimes benefits of installing SPRI to your server are as much as 20% lowered server load. You will need to wget it, untar it, and then run /install.sh from unpacked folder. Continue to Part II |
Similar Mods
Administrative and Maintenance Tools FractalizeR: VBulletin Antivirus | vBulletin 3.7 Add-ons |