Skip to main content

Drupal + CentOS + optimization

I've been working through various optimization issues today and thought i'd share them with my future self and anyone else who reads this.


I'd heard that getting apache to gzip your non-compressed data was a good idea and thought I was probably already doing that with my default apache2 setup on CentOS 4.4. What I learned was that:
  1. For apache2, the relevant module is mod_deflate (it used to be mod_gzip)
  2. My CentOS included the apache module by default, but didn't enable it. I did that according to the excellent documentation on the apache web site.
  3. I found a test site, which says that the html is now about 25% of what it was, saving me bandwidth and increasing the apparent response of my sites.

wim leers

I found a great article about drupal optimization here: improving drupal's page loading performance. He refers to a firefox plug-in developed by Yahoo that looks like a great tool, as well as a list of key issues to analyse for any site, and how those can be addressed in various ways by Drupal. My key understanding here is that php code + mysql optimization is only a small part of the user experience of a fast site.

APC + mysql query cache

Yes, I use APC as my php cache and love it. And i've tuned mysql somewhat to have a reasonable query cache. For handling sudden bursts of traffic (e.g. during the election), this combination is awesome - it means most traffic, even for complex pages, is handled by a bare minimum of cached php and cache mysql calls. Great for the server scaling traffic anyway.

css + javascript

Wim's article above refers to this issue, but it's worth thinking about on it's own. I'd like to use the javascript compressor for all my custom and contrib module javascript and stick it at the end of the page html. And using Drupal's built in css combine/compress mechanism seems more important now - i'd been ignoring it.


The default apache2 setup for CentOS isn't optimized for Drupal - it comes with a lot of extra modules. I haven't done a rigourous paring yet, but would like to report on what I can remove when i do eventually manage that. Also - i'd like to consider having separate apache instances for https and civicrm so that it's more streamlined. I'm also using fastcgi for sympa, which would be nice to split out.

Popular posts from this blog

Me and varnish win against a DDOS attack.

This past month one of my servers experienced her first DDOS - a distributed denial of service attack. A denial of service attack (or DOS) just means an attempt to shut down an internet-based service by overwhelming it with requests. A simple DOS attack is usually relatively easy to deal with using the standard linux firewall called iptables.  The way iptables works is by filtering the traffic based on the incoming request source (i.e., the IP of the attacking machine). The attacking machine's IP can be added into your custom ip tables 'blacklist' to block all traffic from it, and it's quite scalable so the only thing that can be overwhelmed is your actual internet connection, which is hard to do.

The reason a distributed DOS is harder is because the attack is distributed from multiple machines. I first noticed an increase in my traffic about a day after it had started - it wasn't slowing down my machine, but it did show up as a spike in traffic. I quickly saw that…

Upgrading to Drupal 8 with Varnish, Time to Upgrade your Mental Model as well

I've been using Varnish with my Drupal sites for quite a long while (as a replacement to the Drupal anonymous page cache). I've just started using Drupal 8 and naturally want to use Varnish for those sites as well. If you've been using Varnish with Drupal in the past, you've already wrapped your head around the complexities of front-end anonymous page caching, presumably, and you know that the varnish module was responsible for translating/passing the Drupal page cache-clear requests to Varnish - explicitly from the performance page, but also as a side effect of editing nodes, etc.

But if you've been paying attention to Drupal 8, you'll know that it's much smarter about cache clearing. Rather than relying on explicit calls to clear specific or all cached pages, it uses 'cache tags' which require another layer of abstraction in your brain to understand.

Specifically, the previous mechanism in Drupal 7 and earlier was by design 'conservative' …

CiviCRM's invoice_id field and why you should love the hash

I've been banging my head against a distracted cabal of developers who seem to think that a particular CiviCRM core design, which I'm invested in via my contributed code, is bad, and that it's okay to break it.

This post is my attempt to explain why it was a good idea in the first place.

The design in question is the use of a hash function to populate a field called 'invoice_id' in CiviCRM's contribution table. The complaint was that this string is illegible to humans, and not necessary. So a few years ago some code was added to core, that ignores the current value of invoice_id and will overwrite it, when a human-readable invoice is generated.

The complaint about human-readability of course is valid, and the label on the field is misleading, but the solution is terrible for several reasons I've already written about.

In this post, I'd like to explain why the use of the hash value in the invoice_id field is actually a brilliant idea and should be embrac…