Overload Script

taha116

Member
Messages
505
Reaction score
0
Points
16
I am looking for a script that is simple and will automatically display a message if my site is experiencing a server overload, say basically if a page wont load for longer than 30 seconds it will say that automatically
 

garrettroyce

Community Support
Community Support
Messages
5,609
Reaction score
252
Points
63
I think this will work:
Code:
<html>
<head>
<script type="text/javascript>
var t = setTimeout("timeout()", 30000); // function timeout() will be called after 30000ms (30s)
function timeout() {
     var node = document.createTextNode("This is your error message");
     document.getElementById("error").appendNode(node);
}
</script>
</head>
<body>
     <p id="error"></p>
     <!-- other stuff will be happening here. Hopefully it will time out here and not sooner :) -->
     <script type="text/javascript">
          clearTimeout(t); // cancel the error script
     </script>
</body>
</html>

I would consider using a value significantly less than 30. Maybe 5-10 seconds. Most users won't wait 30 seconds for a page to load, browsers will stop trying after too long, and the server will kill the script if it takes too long.. If the server doesn't output enough of the page, this script will also fail. The only time it will work is if you have a server side script that takes too long, either due to server load or the script taking too long.
 

zen-r

Active Member
Messages
1,937
Reaction score
3
Points
38
Wow!

As usual, garrettroyce doesn't just answer questions for people, he completely obliterates the question. Even producing all the coding isn't too much trouble for him. Nice.

I'm tempted to ask him to solve the Meaning of Life for me, when he's got a spare minute. ;)
 

garrettroyce

Community Support
Community Support
Messages
5,609
Reaction score
252
Points
63
42.

Now, you just need the question (any Hitchhiker's guide to the galaxy fans?)

I've been thinking some more about your problem. My guess is you want to have something if X10 is having problems, not because your site is running some really really massive program. In that case, I think you would be better using multiple hosts and providing the nameservers of both hosts to your domain registrar.

I'll walk you through this process if I'm right ;)
 

taha116

Member
Messages
505
Reaction score
0
Points
16
Can you elaborate on your idea? I think im following you but not sure...

And serisoly, if you dont have the answer no one does, what is the meaning of life
 

garrettroyce

Community Support
Community Support
Messages
5,609
Reaction score
252
Points
63
The idea is, if your page starts to load then stops for a long time, an error message will pop up. This will not work, however, if the server is so overloaded and the connection times out. The only time it will probably work is if your script takes too long to execute.

What you can do is have another hosting account at another free host and use both at the same time to display your site. So, if one goes down, the other will still work. However, if you do this, then you have to keep them up to date with each other. If you have a forum, this becomes impossible; just go to paid ;)
 

taha116

Member
Messages
505
Reaction score
0
Points
16
lol, i see the problems with it and they look like they wont allow me to do that, awesome as the idea is. Could i have it redirect to a link of my chosing if the server were to time out or is that not possible?

BTW I would really love your help in developing my MMORPG
 
Last edited:

garrettroyce

Community Support
Community Support
Messages
5,609
Reaction score
252
Points
63
Instead of outputting text to the browser, you could redirect. But, I think you will have the same problems as before. The primary problem for pages is the server does not output anything, not the server only outputting half a page.

I'd be happy to help you with your mmorpg, just as soon as I'm done with my own project ;)
 

taha116

Member
Messages
505
Reaction score
0
Points
16
Ok how long would that project take?

Im bracing myself for a very far away date
 
Last edited:

zen-r

Active Member
Messages
1,937
Reaction score
3
Points
38
Ok how long would that project take?

Im bracing myself for a very far away date

Considering that Garrett's project has been showing at just 1% complete for quite a while now, I think you might have quite a wait on your hands!
 

taha116

Member
Messages
505
Reaction score
0
Points
16
yeah, i know, i saw it too. i am gona ask him if he needs help on that, cuz i could find forum modders to help him out, if he really needs it
 
Top