Recently I worked on a site that required a lot of modules, and when we moved it to our customer's production server it literally took seconds to load a page. Removing modules was not an option. Many people would just say that Drupal is bloated and slow and leave it at that. Sure with a plain vanilla LAMP installation and loads of Drupal modules things can get slow. But don't let that discourage you. The following are my favorite Drupal performance hacks, with their advantages and disadvantages:
Trade something for something else.
For example if you have a lot of memory, but a slow processor, you can try to give more cache to the mysql server to make it faster.
Enable Drupal's default mode page cache (~10 sec)
It generates a cached version from the generated pages, so your server does not have to generate the content for every page query. Advantages: Faster page load time, fewer queries. Disatvantages: It works for anonymous users only.
Enable Drupal agressive mode page cache (~10 sec)
It generates a cached version too, and keep it for longer time. Advantages: Faster page load time, much fewer queries. Disatvantages: It works for anonymous users only. Users may can get outdated contents. It can be buggy with certain modules.
Enable mod_deflate (~2 mins)
Advantages: Faster page loads. Fewer bandthwith use. (If you pay by bandthwidth this is a musthave). Disatvantages: Larger processor load. Some browser support it in a "funny" way.
Enable APC (~10 mins)
APC is an advanced opcode cache supported by the php developers.
If you are using a debian based distro (anyway, are there any other operating systems then Red-Hat, Debian and Gentoo? Don't think so):
apt-get install php-pear php5-dev apache2-prefork-dev build-essential && pecl install apc && apt-get remove php5-dev apache2-prefork-dev build-essential && echo "extension=apc.so" >> /etc/php.d/apc.ini && /etc/init.d/apache2 restart
If you are a fan of red-hat and his friends:
yum install php-pear && yum install php-devel && yum install httpd-devel && pecl install apc && echo "extension=apc.so" > /etc/php.d/apc.ini && /etc/init.d/httpd start
Advantages: APC can make your page load times much much faster, and it require less memory Disatvantages: It can be hard to install.
But before you start hacking: Do you know what makes your server slow? If you don't know the cause you will not be able to fix it. What are your favorite performance hacks?
Kornel is a dedicated software engineer. In the Pronovix he spends his time architecting and developing Drupal-related services. He is a proud member of the International and Hungarian Drupal community, having contributed several modules and core patches. Kornel is enthusiastic about the web, programming and open source technologies, his thirst for knowledge doesn't stop at the computer: in his offline life he is interested in fitness, nutrition and neuroscience.