Here are a few of the steps we use when tuning a Drupal7 system running under Apache/mod_php.
Seperate Servers
The first step is to always put servers in dedicated roles for their task; the performance tips here focus only on the Drupal/PHP/Apache factors in the system. Tuning of database servers, memcached and other steps are not covered here.
Disable Modules/Themes
One very easy step is to disable, and possibily remove completely the moudules that are not in use. Many developer modules are quite heavy; take them out!
APC
To repeat: APC. Install and enable this tool, then locate the apc.php
file that come with the package and put it into a visible web-root.
Look at that page!
apc.enabled="1" apc.shm_size="64M" apc.num_files_hint="600" apc.ttl="3600" apc.user_ttl="7200" apc.gc_ttl="3600" apc.cache_by_default="1" ;apc.filters="" ;apc.mmap_file_mask="/tmp/apcphp5.XXXXXX" apc.slam_defense="0" apc.file_update_protection="1" apc.enable_cli="0" apc.max_file_size="1M" apc.stat="0" apc.write_lock="1" apc.report_autofilter="0" apc.include_once_override="0" apc.rfc1867="0" apc.rfc1867_prefix="upload_" apc.rfc1867_name="APC_UPLOAD_PROGRESS" apc.rfc1867_freq="0" apc.localcache="0" apc.localcache.size="512" apc.coredump_unmap="0"
Notice low fragmentation; near full with low miss rate. Adjust the settings as necessary for your environment.
Sites with more modules would likely need to increase the num_files_hint and the total size in shm_size.
Remember to update the kernel shmmax
.
These commands set the value to 128M, 512M and 1G respectively you may want even more!
~ # echo 134217728 > /proc/sys/kernel/shmmax ~ # echo 536870912 > /proc/sys/kernel/shmmax ~ # echo 1073741824 > /proc/sys/kernel/shmmax
Memcache
Install the memecached system; large scale this is a dedicated server with 90% of the resources (*cough* RAM) is dedicated to memcached. For many smaller installations however (<10,000 nodes) you may be able to get away with memcached running on the web-server.
Once memcached is running it can cached data content for D7; if the proper modules are installed and if the other modules in use can take advantage.
Memcache is also usable for the session, the file handler is very very slow. Update php.ini or your apache.conf files.
# php.ini session.save_handler = memcached session.save_path = localhost:11211
# apache, in Directory or VirtualHost php_value session.save_handler memcached php_value session.save_path localhost:11211
drush pm-download memcache drush pm-enable memcache memcache_admin
Varnish
Varnish is a enormous performance booster for Drupal 7. The easy thing is caching the generated static assets from Drupal; that is JavaScript, CSS and Images. Varnish even caches the generated & then compacted CSS and JavaScript. We have a separate howto on Drupal 7 & Varnish.
Apache Tuning
The above configurations should provide a load of performance improvements for the Drupal sites. If you're still looking for more take a look at our how on Apache performance.