Key manual:

Install XHProf

I made sure xhprof-0.9.2 was installed inside the www-directory of the webserver.

tar xvf xhprof-0.9.2.tgz
cd ./xhprof-0.9.2/extension/
./configure --with-php-config=/usr/local/bin/php-config
sudo make
sudo make install
sudo make test

The php-config file on my machine was located in /usr/local/php-config . Php-config is a file that lists the location of your php-installation. Xhprof needs it for its configuration. If you can’t find the file, you can simply execute ./configure without the parameter.

If phpize is not found, you have to install php5-dev

sudo apt-get install php5-dev

The first time, “make install” and the “make test” both failed with me, but xhprof worked nevertheless.

Set up PHP

In php.ini I set up this at the end of the file:


Create the directory: /var/tmp/xhprof

xhprof will keep its logfiles in there (files that are needed for the page analysis)

Set up your webserver

Create an entry for /path/to/xhprof-0.9.2/ in your webserver’s configuration (point xhprof.localhost to the /path/to/xhprof-0.9.2/. If local, setup your hostfile correctly (eg:  xhprof.localhost)

Restart php and your webserver.

Set up Drupal

When using Drupal, install Devel, and activate the XHProf settings (admin/settings/devel) and point to /path/to/xhprof-0.9.2/ and the path to the website: http://xhprof.localhost/xhprof_html

Devel will create a link at the end of each page that points to XHProf.


If you get the error that the function xhprof_enable is unknown, then it’s because XHProf wasn’t properly installed. Try to install it again and make sure you have restarted php.

If the link in Drupal to XHProf doesn’t work, check if the run parameter in the url is supplied. If not, try to install XHProf again and make sure you have restarted php. A typical error for this is: “No XHProf runs specified in the URL.

For errors concerning php-config and phpize, see above.

Let’s face it: Drupal can be a snail. When you attract lots of visitors, or have a lot of content, you performance will go down. To speed up Drupal, you need to install other software on your server that will make it appear like Drupal goes faster (but in fact stays as slow).

You can do any of these or a combination of these:

  1. Use memcache. Memcache replaces the classic cache-database-tables and puts the cache in the RAM (instead of in the database). This is the fastest way of getting your data.
  2. Use nginx instead of Apache. Nginx is a lightweight webserver that can handle more traffic than Apache. While it will not make your site magically faster, it can surely help up.
  3. Code-improvements in Drupal:
    • Disable menu_rebuild every time a view is saved. Run menu_rebuild only when cache clear is explicitly asked. (this is in fact core hacking, which is wildly disapproved, but it clearly helps)
    • Rewrite heavy queries generated by Views. Views don’t make the nicest queries. Certainly complex views can be made faster when you edit the query yourself. You can do this with a module that hooks into the view.
    • Check for node_load() calls everywhere. These functions eat up memory and should be replaced where possible (a custom query could do). You wouldn’t believe what happens when you call node_load().
    • Cron:
      • inspect all the cron hooks in your Drupal installation. Decide if the tasks are really necessary, and/or edit them. You’ll notice that the cron spends most of its time with indexing the search words.
      • Use visitorstats (like Google Analytics) to see when traffic peeks. If your website peeks at noon, edit the crontab and disable cron around that time. At least all cpu will go to your visitors. (make sure there are no real important tasks to be done). Cron should run “just enough”. I set my cron to run every hour from 11PM to 7AM.
      • Drupal calls home once a day to see if there updates for modules (with fread). This action consumes cpu. I think that once a week is more than enough. Even every forthnight. You can always check for new modules manually.
    • * In order to do find bottlenecks:
      • Use the Devel module. It displays all queries that are made to the database.
      • Use XHProf. A free php-profiler developed by Facebook to find slow components. It displays function calls and generates a graph (also install Dot for that). My article on how to install XHProf.
      • If you have the possibility, use New Relic, a tool similar to XHProf, but more advanced.
  4. Boost: Boost is a Drupal module that caches entire  webpages as static html files for anonymous users. You wouldn’t believe what a boost that gives. However: take in consideration that websites with a lot of content changes will need to refresh this cache a lot. It’ll take some time to configure. Still, it doesn’t speed-up the admin-environment in any way. This article explains how to install Boost with Nginx [].
  5. Varnish: A similar, but better, approach to Boost is Varnish. Varnish also caches pages, but puts them in the RAM, while Boost uses the hard discs (and creates amounts of files). A downside of Varnish is that it’s complex to set up (you have to put it in front of your webserver) and is difficult to config. With Varnish Drupal can’t use anonymous cookies, so you have to patch your entire Drupal setup, and use “Pressflow” as Drupal core instead of the regular Drupal releases (this is just for Drupal 6). Any module that uses sessions will have to be patched. Varnish however promises what it delivers and gives a serious boost to your website and is far more advanced than Boost. My article on how to install Varnish.
  6. If you can afford it, use a seperate (database) server. Drupal generates a lot of cpu-pressure. This makes the database on the server getting less cpu. Some queries take x50 times as much time as on a non busy site. By taking the heath of the database, this should give a performance boost.


This articles covers the installation and configuration of Nginx+Varnish+Drupal6(Pressflow) and also about the Purge module.

This article assumes:

  • you are no Drupal newbie
  • you know about the default Drupal caching
  • you have some experience with Nginx (if you have Apache as webserver, this tutorial might help you too.)
  • you know what Varnish is.

Note: I’m still updating this post. It’s a bit messy right now.

Install Varnish (the easy part)


curl | apt-key add


sudo su

(enter password)


echo "deb lucid varnish-2.1" >> /etc/apt/sources.list

Note: I installed 2.1, The latest version is 3.0. You can install 3.0 by altering the above line.

(see: )

Continue reading “Install Varnish (with Drupal and Nginx)”…

  • Published:April 2nd, 2012
  • Category:cron

Making changes to cron in a terminal is a rather dodgy process (if you’re used to Windows).

1) Log on to the server, type:


You’ll notice it’s a read only environment.

2) To edit press the <insert> key on your keyboard.

3) Make changes. (running cron 4 times an houre is: */4 * * * * … in the first line. Running cron every houre is just: 0 * * * *… (the 0 is the minute to start. If you want to start it 10 minutes past the houre, type: 10 * * * *… )

4) To save and exit, press the <escape> key on your keyboard.

5) Type:


6) Press the <enter> key on your keyboard. The editor should disappear and a message “installing new crontab” should come up.

To change the location of your Firefox-profile folder (or to move it to another computer):

  1. Copy the folder of your profile to the new location (the folder mostly has a random name. you can look it up by opening the profile manager (see down))
  2. Open profiles.ini in the firefox program folder (c:\program files\… on Windows), and change the location of your profile folder.
  3. Other paths also need to be adapted in ini-files in the profile folder. This is because Firefox uses absolute paths and no relative paths. Use a text-tool to look up the ini-files where the folder locations are stored.
  4. Try to run Firefox with the profile manager. If things don’t work out (eg: if your profile looks wrong or incomplete); remove the following files in the root of the profile folder. The next time firefox starts, it will recreate these files with the correct file paths.
  • compreg.dat
  • extensions.cache
  • extensions.ini
  • extensions.rdf
  • pluginreg.dat

To launch the profile manager (linux):

firefox -ProfileManager


« Previous Page clearPaper by Copyright © 2012-2019 Robin Brackez. All rights reserved. By visiting this site you agree to accept cookies that are purely used to check how many visitors I have. Theme by: creativebits. Custom adaptations by Robin Brackez.