Tips to increase your drupal website website performance!!!


Things we need to increase performance-
1>Things which can be done in Drupal admin settings section:-
  - Enable Caching
  - Enable CSS Compression and Aggregation (
Log in to your Drupal admin area and go to Site Configuration > Performance. Besides enabling cache, you should also enable Page compressionOptimize CSS files and Optimize JavaScript files.)
  - Go to MySQL and Enable Query cache in MySql
  - Go to PHP and Add a PHP OpCode Cache (APC)
Disable/remove all modules/blocks you are not using.

 

Anonymous User caching

  - Set up a Reverse Proxy Cache (this keeps pages in memory and serves anonymous visitors cache page through RAM instead of dynamically via the database). For Pressflow 6 & Drupal 6 sites, set up the Reverse Proxy Cache using VARNISH (http://varnish-cache.org). However, for a Drupal 5 site, it's harder to setup a Reverse Proxy Cache, so instead of Varnish, We instead recommend using the Boost module (http://drupal.org/project/boost)
A good cache lifetime is 5 minutes, or 12 times an hour.

 

Authenticated User caching

Use Memcache (http://drupal.org/project/memcache and http://memcached.org) along with Pathcache (http://drupal.org/project/pathcache) for drupal lookup path queries.
This puts most authenticated user queries into memory (RAM)

 

We should have at least 2 Servers (if possible)
Best practice for scaling is to have at least 2 servers; one dedicated server for content, and a seperate server just for the Database. Then optimize each server for its specific task. Ideally, both are powerful servers, but if you have to choose, give the Database more resources.
MySQL Tuning
The recommended settings in the /etc/my.cnf file for a Drupal-based website are:
max_connections = 800
max_user_connections = 800
key_buffer = 36M
myisam_sort_buffer_size = 64M
join_buffer_size = 2M
read_buffer_size = 2M
sort_buffer_size = 3M
table_cache = 1024
thread_cache_size = 286
interactive_timeout = 25
wait_timeout = 1800
connect_timeout = 10
max_allowed_packet = 1M
max_connect_errors = 999999
query_cache_limit = 1M
query_cache_size = 16M
query_cache_type = 1
tmp_table_size = 16M

 

Apache Server ( Enabling Compression ):-
<Location />

 

# Insert filter
SetOutputFilter DEFLATE
# Netscape 4.x has some problems...
BrowserMatch ^Mozilla/4 gzip-only-text/html
# Netscape 4.06-4.08 have some more problems
BrowserMatch ^Mozilla/4\.0[678] no-gzip
# MSIE masquerades as Netscape, but it is fine
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
# Don't compress images
SetEnvIfNoCase Request_URI \
\.(?:gif|jpe?g|png)$ no-gzip dont-vary
# Make sure proxies don't deliver the wrong content
Header append Vary User-Agent env=!dont-vary
</Location>
Or in latest way use mod_filter as specified in below link

 

 
More on Apache Level Caching
Add the file conf.d/cache.conf to your Apache config: -
NEW: We now add Expires headers as well as the Cache-Controlheaders to ensure optimal caching behavoir in all browsers.

 

# Caching by default options...
# cache static content in local disk cache for performance..
<IfModule !cache_module>
        LoadModule cache_module modules/mod_cache.so
</IfModule>
<IfModule cache_module>
    <IfModule !disk_cache_module>
            LoadModule disk_cache_module modules/mod_disk_cache.so
    </IfModule>
        CacheRoot /data/apache/cache
        CacheEnable disk /
        CacheDirLevels 5
        CacheDirLength 3
        CacheIgnoreHeaders Set-Cookie
    CacheIgnoreQueryString On
    CacheLock on
    CacheLockPath /tmp/mod_cache-lock
    CacheLockMaxAge 5
</IfModule>

 

# some resonable default caching rules based on filetypes..
# Do not cache html or php
<FilesMatch "\.(?i:html?|php|sh|ksh|pp|rb|pl)$">
        Header set Cache-Control "no-cache, no-store, must-revalidate"
</FilesMatch>
# Cache CSS and JavaScript for 1 day.
<FilesMatch "\.(?i:js|css)$">
        Header set Cache-Control "max-age=86400, public"
        ExpiresActive On
        ExpiresDefault "access plus 1 day"
</FilesMatch>

 

# Cache these files for a day...
<FilesMatch "\.(?i:pdf|swf|txt)$">
        Header set Cache-Control "max-age=86400, public"
        ExpiresActive On
        ExpiresDefault "access plus 1 day"
</FilesMatch>
# Cache icons and shockwave flash for 1 month.

 

<FilesMatch "\.(?i:flv|ico)$">
        Header set Cache-Control "max-age=2678400, public"
        ExpiresActive On
        ExpiresDefault "access plus 1 month"
</FilesMatch>
# Cache images for a month...
<FilesMatch "\.(?i:jpe?g|png|gif|svg)$">
        Header set Cache-Control "max-age=2678400, public"
        ExpiresActive On
        ExpiresDefault "access plus 1 month"
</FilesMatch>
# Cache fonts for a month
<FilesMatch "\.(?i:eot|woff|ttf|otf)$">
        Header set Cache-Control "max-age=2678400, public"
        ExpiresActive On
        ExpiresDefault "access plus 1 month"
</FilesMatch>
# Use a simple ETag without inode in it
FileETag MTime Size
This config does three different things to improve speed: -
1.    Set cache-control headers on files that can be cached and not asked for each time
2.    Enable the apache disk_cache to cache any page which is declared as cacheable.
3.    Specify an ETag which does not include the content's file inode.

 

Keep-Alives - ask for things in batches
Keep-Alives also can have a major effect on website performance.  They allow a browser to reuse an open TCP/IP connection to load multiple resources from the webserver.  Without it, the browser has to close and re-open a new connection for each item it downloads, which is expensive, especially if you are located on a network a long way away from the web server.  As even a simple web page can contain 50 or more assets, creating a new connection for each will really slow you down.  Rather than turn this off, we want to enable and if then tune it as necessary. 

 

#
# KeepAlive: Whether or not to allow persistent connections (more than
# one request per connection). Set to "Off" to deactivate.
#
KeepAlive On
#
# MaxKeepAliveRequests: The maximum number of requests to allow
# during a persistent connection. Set to 0 to allow an unlimited amount.
# We recommend you leave this number high, for maximum performance.
#
MaxKeepAliveRequests 100
#
# KeepAliveTimeout: Number of seconds to wait for the next request from the
# same client on the same connection.
#
KeepAliveTimeout 5
Enable GZIP components
Apart From this 4 main things we need to do to increase performance are
1>Convert MyIsam to Innodb for larger database which will enable row level locking for tables than table level which is there in MyIsam case
2>Add proper indexing to all required tables which will increase performance substantially and each query will take at-least 3 times lesser time than current time, may be lesser than that.
3>Check out for the connection type drupal/mysql is using that is whether its persistent connection or non-persistent connection and how many maximum connections are allowed during particular time.
4>Whether your server is shared server or dedicated server and whats the amount of bandwidth assigned to your site if its shared server for particular time.
No comments

Enter your email address:

Delivered by FeedBurner

OR

 Subscribe in a reader

 
Latest Blogs
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
Tips for optimizing php code by PHP Expert Important SERVER Variables in PHP - By PHP Expert Improved Error Messages in PHP 5 - By PHP Expert New Object Oriented Features - By PHP Expert New Object Oriented Features - By PHP Expert New Object Oriented Features - By PHP Expert New Object Oriented Features - By PHP Expert New Object Oriented Features - By PHP Expert New Object Oriented Features - By PHP Expert New Object Oriented Features - By PHP Expert Object Overloading in PHP 5 Persistable Classes - By PHP Expert Dynamic Getter/Setter Methods - By PHP Expert New Functions in PHP 5 New Directives - By PHP Expert Exception Handling - By PHP Expert Password Encryption in PHP - By PHP Expert Output Buffering in PHP - By PHP Expert Page Excerpts Using CURL - By PHP Expert Quick and Easy Google Site Search - By PHP Expert Always Be Notified When Google Crawls Your Site - By PHP Expert How to POST Form Data using CURL - By PHP Expert Cryptography for web developers - By PHP Expert Dynamically Loading JavaScript Files - by PHP Expert What is Web 2.0 - By PHP Expert