FractalizeR: VBulletin 4 extensive optimization guide (Part II)
by
03 May 2010
Rating: (2 votes
- 4.50 average)
Continuation from Part I Install mod_evasive and DDOSDeflate script If your forum is a constant target for DDOS attacks, to lower their performance impact, you can install Apache module http://www.zdziarski.com/blog/?page_id=442 and http://www.inetbase.com/scripts/ddos/ scripts. mod_evasive installation guides are scattered across the net, so I leave you with Google on its installation. As for DDOS Deflate, just wget http://www.inetbase.com/scripts/ddos/install.sh and run it (dont forget to chmod u+x it first). Generally these two doesnt need to be tuned and their default settings are ok. Move Avatars and Profile Pics to the file system You need to move pictures to the filesystem as well. Go to your AdminCP, expand the Avatars menu on the left side and click User Picture Storage Type. Move CSS to the file system Go to your AdminCP, expand the vBulletin Options menu and select vBulletin options. From there select Style and Language Options in the drop down menu. Then set Store CSS Stylesheets as Files? to Yes and click Submit. Enable caching of static content This option will tell user browser to download files from your website less often thus decreasing server load and improving page load times for user. You will have to have mod_expires active in Apache. Add the following to .htaccess in the forum root Code:
## Expires <IfModule mod_expires.c> ExpiresActive On ExpiresDefault "access plus 1 seconds" ExpiresByType text/html "access plus 1 seconds" ExpiresByType image/gif "access plus 3456000 seconds" ExpiresByType image/jpeg "access plus 3456000 seconds" ExpiresByType image/png "access plus 3456000 seconds" ExpiresByType text/css "access plus 3456000 seconds" ExpiresByType text/javascript "access plus 3456000 seconds" ExpiresByType application/x-javascript "access plus 3456000 seconds" ExpiresByType application/javascript "access plus 3456000 seconds" </IfModule> Install and attach MemCached Consider installing and attaching MemCached to VBulletin (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 MemCached from there using yum install memcached after. Dont forget to issue chkconfig memcached on to make sure memcached will auto-start on next server reboot). You will need to edit your /includes/config.php and uncomment the following lines there: PHP Code:
$config['Datastore']['class'] = 'vB_Datastore_Memcached';
OPTIONS="-l 127.0.0.1" InnoDB: Migrating Consider http://www.vbulletin.com/forum/entry.php?2413-Part-2-vB4mance-vBulletin4-Optimization-Basic-Guide-to-InnoDB-Conversion to improve concurrency if you have a really large forum and you want to make it faster. Please note, that on small forums (or on servers with a little of physical memory) this option can even slow things a bit. Be sure you have at least 2-4Gb RAM on your server before considering InnoDB migration. InnoDB: increase innodb_buffer_pool_size If you migrated to InnoDB, you need to increase http://www.mysqlperformanceblog.com/2007/11/03/choosing-innodb_buffer_pool_size/ to at least 512Mb depending on your server free RAM available. It is the memory area, used to cache data for InnoDB tables and by default it is very small (8Mb only, suitable for Pentium 166MMX home machine with database of your video tapes). If your server is running something else together with VBulletin, please consult with your server administrator for this change since it is server-wide. InnoDB: lower transaction isolation level VBulletin is running in autocommit mode and does not really use transactions. Default InnoDB transaction isolation level is REPEATABLE READ, which leads to excessive use of system resources in autocommit mode. You can lower it to READ COMMITTED. If you run ONLY VBulletin on your server, to lower transaction isolation level you need to add the following line to /etc/my.cnf (MySQL main configuration file): Code:
transaction-isolation = READ-COMMITTED PHP Code:
$this->sql = "SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED";
Tune MySQL for your forum There are several ways to optimize your MySQL server even if you are not a professional DBA. One is to open PHPMyAdmin, go to Status tab to see server status and look for values in red color there. You will find some hints next to them (although, they could be not so clear). Another is to use various MySQL analysis scripts, that analyze MySQL status reported by server themselves. You can get one http://www.day32.com/MySQL/ (its a bash script, you need to wget it, then chmod u+x tuning-primer.sh, and then execute: ./tuning-primer.sh) and another in Perl http://blog.mysqltuner.com/download/. They report more understandable resuts. Before making changes to your my.cnf, please, consider making a backup of it so that you could easily revert corrupted or unoptimal settings. Optimize your MySQL tables regularly Consider running the following simple script every several weeks depending on forum load (of course, you should run it at nights when your forum is the least loaded) PHP Code:
<?php
You can add it to Linux cron if you like. Consider moving to newer MySQL server version Generally, newer MySQL server versions are more clever. They know how to optimize queries better, how to handle resources better etc. So, you may receive a small benefit from moving to a newer MySQL server version. If you are on CentOS or RedHat this is complicated, because default repositories have only 5.0 version of MySQL server. So, I cannot recomment that. But you can always get RPM from MySQL http://www.mysql.com/ and install it. If you are an IT geek, you can even move to Percona MySQL server. This is a tweaked MySQL server with some optimization patches (from Google for example) applied and improved InnoDB performance. Unlike Oracles MySQL, Percona has own RPM repository, that can be installed using http://www.percona.com/percona-builds/percona-release/ rpm. Despite performance gains, I dont recommend this until you are really in need because maintaining another version of MySQL different from the one provided with your OS by default will take much time and resources from you. Turn off apache modules, that you dont need Consider turning off all apache modules you dont use on server, that holds your forum. For example, on my server httpd.conf has the following LoadModule configuration part: Code:
LoadModule auth_basic_module modules/mod_auth_basic.so #LoadModule auth_digest_module modules/mod_auth_digest.so LoadModule authn_file_module modules/mod_authn_file.so #LoadModule authn_alias_module modules/mod_authn_alias.so #LoadModule authn_anon_module modules/mod_authn_anon.so #LoadModule authn_dbm_module modules/mod_authn_dbm.so #LoadModule authn_default_module modules/mod_authn_default.so LoadModule authz_host_module modules/mod_authz_host.so LoadModule authz_user_module modules/mod_authz_user.so #LoadModule authz_owner_module modules/mod_authz_owner.so #LoadModule authz_groupfile_module modules/mod_authz_groupfile.so #LoadModule authz_dbm_module modules/mod_authz_dbm.so #LoadModule authz_default_module modules/mod_authz_default.so #LoadModule ldap_module modules/mod_ldap.so #LoadModule authnz_ldap_module modules/mod_authnz_ldap.so LoadModule include_module modules/mod_include.so LoadModule log_config_module modules/mod_log_config.so LoadModule logio_module modules/mod_logio.so LoadModule env_module modules/mod_env.so LoadModule ext_filter_module modules/mod_ext_filter.so LoadModule mime_magic_module modules/mod_mime_magic.so LoadModule expires_module modules/mod_expires.so LoadModule deflate_module modules/mod_deflate.so LoadModule headers_module modules/mod_headers.so #LoadModule usertrack_module modules/mod_usertrack.so LoadModule setenvif_module modules/mod_setenvif.so LoadModule mime_module modules/mod_mime.so #LoadModule dav_module modules/mod_dav.so #LoadModule status_module modules/mod_status.so #LoadModule autoindex_module modules/mod_autoindex.so #LoadModule info_module modules/mod_info.so #LoadModule dav_fs_module modules/mod_dav_fs.so #LoadModule vhost_alias_module modules/mod_vhost_alias.so LoadModule negotiation_module modules/mod_negotiation.so LoadModule dir_module modules/mod_dir.so #LoadModule actions_module modules/mod_actions.so #LoadModule speling_module modules/mod_speling.so #LoadModule userdir_module modules/mod_userdir.so LoadModule alias_module modules/mod_alias.so LoadModule rewrite_module modules/mod_rewrite.so #LoadModule proxy_module modules/mod_proxy.so #LoadModule proxy_balancer_module modules/mod_proxy_balancer.so #LoadModule proxy_ftp_module modules/mod_proxy_ftp.so #LoadModule proxy_http_module modules/mod_proxy_http.so #LoadModule proxy_connect_module modules/mod_proxy_connect.so #LoadModule cache_module modules/mod_cache.so #LoadModule suexec_module modules/mod_suexec.so #LoadModule disk_cache_module modules/mod_disk_cache.so #LoadModule file_cache_module modules/mod_file_cache.so #LoadModule mem_cache_module modules/mod_mem_cache.so LoadModule cgi_module modules/mod_cgi.so LoadModule version_module modules/mod_version.so Enable KeepAlive in Apache settings KeepAlive setting allows Apache server to send replies to several requests over the same TCP connection. This is of course faster than to open new TCP connection for each resource sent. To enable KeepAlive search for KeepAlive in apache configuration file (httpd.conf) and set it to On: Code:
KeepAlive On Turn off PHP modules you dont need VBulletin uses the following PHP modules: gd, iconv, mbstring, mysql or mysqli (depending on your VBulletin database connection settings). All others (except for those, that are compiled with PHP by default and were not disabled using disable-XXX switch during PHP compilation) are not required. You can skip loading them to make PHP occupy less memory and start faster. On RedHat and CentOS you can just comment extension= lines in each corresponding file inside /etc/php.d directory. Turn on PHP bytecode caching If
Code:
yum install php-devel pecl install APC Code:
yum install autoconf libtool gcc gcc-c++ Optimizations, that will speed up forum for users, but may increase server load Enable compression of content If you have some spare CPU power and want to make your forum load faster for users, you can also enable static content compression. You will have to have both mod_headers and mod_deflate active in Apache. Add the following to your .htaccess in the forum root: Code:
#Compression <IfModule mod_headers.c> <IfModule mod_deflate.c> AddOutputFilterByType DEFLATE text/css text/xml text/javascript application/x-javascript application/javascript BrowserMatch ^Mozilla/4 gzip-only-text/html BrowserMatch ^Mozilla/4\.0[678] no-gzip BrowserMatch \bMSIE !no-gzip !gzip-only-text/html </IfModule> </IfModule> Forum settings, that seriously affect database performance You can tune all below if your forum causes great load to database
|
Similar Mods
Administrative and Maintenance Tools FractalizeR: VBulletin Antivirus | vBulletin 3.7 Add-ons |