0

If a website receives too many connections at the same time (overloaded by a lot of users visiting the website at the same time), is there a way to direct users to a static html page automatically?

I'm not sure if I am on the right track but would this land with the htaccess file where if the user spends an x amount of time trying to connect to the server, it would just show them a static html error page instead?

If so... Which error page should I be creating (408 timeout?) and how could I set it so that if the user attempts to connect for about 10 seconds it should automatically direct them to that static html error page?

Below is what I would personally put in the htaccess if I want custom error pages but how would I be able to direct them to that page if they can't load a page after 10 seconds?

ErrorDocument 404 /custom404.html

# Can also do the same for other errors...
ErrorDocument 500 /custom500.html

EDIT

So as an example, if the website deals with tracking airplane flights and an airplane suddenly goes missing, a lot of people are going to start flooding that site immediately. So assuming that it's more than what the server can handle, I would assume that users will end up waiting for a while to connect to the server? If so, would that then result to an error page or would they just keep on waiting?

chdltest
  • 853
  • 2
  • 6
  • 18
  • If users cannot connect to the server... how do you imagine the htaccess file, or static pages, would be helpful? – Sverri M. Olsen Jan 08 '15 at 17:46
  • If your visitors have to wait 10 seconds then you should look to improve that situation. Either you have serious performance issues, or you are on a 50 cents hosting and you should upgrade. – Lorenz Meyer Jan 08 '15 at 17:48
  • Alright, I gave an example of the situation in hopes that it explains as to what would be out of my control in terms of the server specs or what sort of issue I'd be dealing with exactly. – chdltest Jan 08 '15 at 17:49
  • I guess every server (and client, too ?) in the world has some sort of timeout that will *eventually* always bring you to an error message if users have to wait *indefinitely* – sodawillow Jan 08 '15 at 18:52
  • @sodawillow I guess my assumption about the whole 500 error thing is correct then? So... all I really need to do is make a custom error page and have the htaccess point to it when the time comes. I hope I'm right, haha. Wish someone who knew a lot about this could clarify. – chdltest Jan 08 '15 at 19:45
  • Hard to say ... how will the server serve your error page if it is not serving ... (looping here, sorry) – sodawillow Jan 08 '15 at 19:46
  • Typically if you have "web server error" it will not serve your custom Error page because it's not serving anything, you will get default 500 page. The custom 500 pages will only come from other resources that trigger the error such as a syntax error in PHP or something along those lines. – Panama Jack Jan 08 '15 at 19:53
  • So is there a way to detect if the loading is taking too long and then to direct them to a custom error page? – chdltest Jan 08 '15 at 20:05
  • You could use Nginx as a reverse proxy that sits in front of apache then you can check the upstream and if apache webserver is not responding then throw up custom 500. http://stackoverflow.com/questions/5031818/show-a-custom-503-page-if-upstream-is-down – Panama Jack Jan 08 '15 at 22:14

1 Answers1

0

You could possibly accomplish this by passing the page through another server. Basically, you have a page on server A that is public and the user gets to. Then this page tries to pull your actual page from server B with AJAX, if it fails it displays an error.

It would be just plain JScript and HTML so the load on server A wouldnt be as high.

BlackCetha
  • 2,051
  • 1
  • 15
  • 15