Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

My site has been largely unresponsive for three days due to a large amount of traffic.

A JavaScript element on the page regularly requested images from the server, and the number of connections became a problem as people left their browser windows open (and therefore never stopped requesting the images).

I redesigned the site to use a single sprite and load it only once; however, now there's a massive amount of 404 errors as people still attempt to load the old content. The site is on a VPS, and it's unusable due to the latency.

To make matters worse, I had initially assumed the latency was due to a lack of caching. I added a directive to the .htaccess file for visitors to cache resources (the old, inefficient code included).

My host has been unable to rectify the problem. What can be done to force the persistent connections to stop trying to load obsolete content?

share|improve this question

You can't really stop someone from making a request to a non-existent resource (e.g. anyone can make up a URL for a page that doesn't exist and get a 404). However, there may be some things you can do to improve the situation.

Firstly, change the filename on your new content - if you still reference a javascript file in your html, ensure it has a different name than the one with the problem, so that the browser will not used the cached copy.

Secondly, make your 404 page as simple as possible (definitely go for a static page, not something dynamic, and very small).

Thirdly, Apache is not that efficient at handling large numbers of concurrent requests without a lot of available memory (it launches one worker thread per request). Consider (at least temporarily) adding another server in front of Apache that will handle the 404 requests more efficiently. Some examples might include:

  • nginx - have it serve the 404 requests (and possibly all static files), and proxy_pass other requests back to Apache (and it can also cache proxied requests)
  • Varnish - it can cache the 404 request and serve it directly from memory, reducing the load on Apache
share|improve this answer
Would banning the offending IP addresses on the server's firewall make a difference? – Peter Dec 22 '11 at 17:37
While you could block IP addresses - how would you know which ones (iptables doesn't process the http request in any way - it is only going to look at the port, source, and destination) - you can't block 'just the 404 requests' with iptables - you would need to know the IPs; and if you block any requests, you will block all requests from that IP (you can set up some limits, but will lose a lot of legitimate traffic). The firewall layer doesn't speak http - you need to work at the layer that does for an effective solution. – cyberx86 Dec 22 '11 at 21:09

I would start by immediately creating a zero-byte file to get rid of the 404's and minimize the cost of each retrieval.

share|improve this answer
up vote 0 down vote accepted

A system administrator at my host solved it with a script:

Any IP address that tries to access the old content (by nature, an such a user is continually making requests and consuming connections) is immediately added to the server's firewall. So far, just a few hundred (of many thousands of visitors) have been detected and blocked. The solution is working very well.

share|improve this answer
Seems a bit drastic, like cutting off your own nose. Couldn't you just redirect the users to a 404 page explaining the new layout? Also you really shouldn't change urls – dalore Feb 12 '15 at 14:57

Your Answer


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.