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%!!

Advertisements

One thought on “Apache redirects and performance issues

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s