Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

My server has recieved sudden increase in the (read) web traffic, requesting many map image tiles, and apache cannot handle it.

Apache cannot even handle the redirections! The average load I get in my CentOS machine is more then 200..

Is there some software out there that can redirect SOME of the traffic, such as only the traffic from specific directory (such as http://example.com/maptiles/abc.png) to a different address (sucha as http://s3.amazonaws.com/mytiles/abc.png) ?

can this be done by HAProxy?

share|improve this question
    
Use Load Balancing, man.. –  Sachin Shekhar Apr 9 '12 at 9:30

3 Answers 3

You could do that, but before you go to that extreme, consider improving the performance of your existing service, including (perhaps) putting in a caching reverse proxy such as Varnish. By the time you get to the point where your only option is proxying some traffic out to S3, you're probably going to be dead in the water anyway.

What you might want to consider doing instead is putting some content on a separate subdomain (such as maptiles.example.com), pointing that to S3, and changing the links to those assets in your site code to reference that subdomain. That'll take a fair chunk of load off your machine.

share|improve this answer
    
Thanks a lot. I think cacheing is not an option, since most of the data is static, but I'll check it. The sub domain idea is great, but the problem is that the traffic also comes from an iOS app that cannot be changed easly. I'll do that in the app and submit it to Apple. The problem is that the site is dead now, and this is the most important time of the year (holidays). –  yoav r Apr 9 '12 at 9:44
1  
You really needed to be thinking of this before you got busy -- or you should have sought the advice of experts to manage your infrastructure in advance, so you could effectively manage these sorts of peak periods. –  womble Apr 9 '12 at 10:36

If you think your server reached its limit, you can use haproxy as load balancer and direct all traffic to it. Then, it will redirect the requests to the configured backends. Some of the great features of haproxy include:

  1. Health-check of backend servers.
  2. Very flexible ACLs can be built to redirect traffic.
  3. Stable and can handle many many concurrent connections.
share|improve this answer

I'd say you should install - better if you can do it on a dedicated instance, but would also work on the same - an instance of NGINX (a simple event webserver/beautiful load balancer solution) in front of your apache web server.

You could add a Varnish cache (to NGINX, if you have enough RAM available) to manage those static request internally, without involving your apache setup. This is a very simple setup that would allow you to grow horizontally (adding more server with Apache and doing the redirect to them from NGINX).

You should also understand where your bottleneck are located. Load of 200+ could be related to high CPU (maybe you have MySQL running locally and you are missing indexes?), or to disk I/O (look at iowait% from iostat GNU/Linux command) which could be related to those static files requests.

Understanding the bottleneck should be the first step then offload everything you can.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.