Alternatives for a web application architecture

The guys at DigitalOcean have written a great article with the choices you have when designing your webapp insfrastructure needs:

good read!


Improve performance and speed in Apache

We have given some ideas about how to gain performance in some Apache tasks such as redirection.

In this post, I would like to point out some basic ideas about improving performance with an Apache server. I will refer to version 2.2. running in Ubuntu server 12.04 32 bits.

1. Activate the Apache Cache

Apache has several modules that provide cache services. This guide explains a little bit the modules available:

And DigitalOcean provides a more practical look at it with straightforward tips

So the simplest approach is to enable the module:

sudo nano /etc/apache2/mods-available/mem_cache.conf

where you will see the configuration. I have not changed nothing for the moment.

And then, make it run:

sudo a2enmod mem_cache

service apache2 restart

This part so far is covering the Memory Cache. I will not talk about the Disk Cache, since I am using the WordPress SuperCache plugin and would not like to have a conflict between both.

2. Allow Override none Directive

If you have set “Allow Override none” then Apache will look in every folder to find an .htaccess file. But it is most likely that you only have one .htaccess file, and not a whole cascade of .htaccess files, so, why not put it in the configuration file and save time? the benchmark shown by the excellent post by ESchrade is very convincing. This idea is also reinforced by this post

This action is also recommended in this great post with tips for improving Apache speed

3. Use third party cache software

If you are using WordPress, it is highly recommended to use the WordPress SuperCache Plugin. More info here

There is also a more generic option, called Varnish,, and also a nice configuration guide by Donncha Ó Caoimh

4. Offload unused modules

This is thoroughly explained here As well as other great ideas such as

5. Reduce number of connections

Same link as above.

6. Set the right number of MaxClients

In short, this is the formula that you have to use to calculate the number of MaxClients:

(Total RAM – RAM used for Linux, MySQL, etc.) / Average httpd process size

There is a script here that will help you to get this for your server:

More details on this can be found in this link:

7. KeepAlive On or KeepAlive Off?

This is not an easy one, I have turned it to KeepAlive Off, and the server works much better now. If you want a detail explanation check out:

8. Define Spare Servers

In this post there is a useful guide for that:


Do you know of other ways of improving Apache performance? Please get in touch with us and help us complete this guide!

Apache redirects and performance issues

Where should you put a redirection rule in Apache?

This is the story: I am serving a widget for a client, on their homepage. This client has a huge amount of traffic, much more than what I normally have for my application.

So the first thing I did was to convert this widget into a static file. And serve it from Amazon. But then I had to request the client to change the name of the file to be requested. And before doing that I decided to try out the redirection myself

I started using php header() function. But I realised that using php redirection was a bit overkill.

So I switched to Apache redirection. And my first idea was to use .htaccess.

And it worked nicely. But the CPU of the server, according to New Relic was working too much. So I wondered again, how could this get better? And I remembered that Apache allows to put the redirection directives already in the virtual host configuration file. So this is what I did. I looked into /etc/apache2/sites-available and put the redirection line into the virtual host configuration.

It worked like a breeze! the server is now running like a bullet. And the apache processes, acording to top are now consuming between 1-1.5% of processing power. Beforehand it was above 4%!!

mysql keeps crashing, how to solve it?

I am using a very simple digitalocean basic server with 512mb RAM, and using Ubuntu 12.04 64bits

I tried the recommendations here:

But still keeps crashing, so I have looked for further information, and this one seems to be a good guide to tweak the server, both apache and mysql:

I think that the key point for me is that I chose Ubuntu 64 bits without being aware that 64 bits Ubuntu takes around 50% more memory than 32 bits

So now I guess the solution is to downgrade to a 32bit server, which will be a bit of a pain… but if this solves the performance issue, then I will surely do it.