views:

113

answers:

5

I have a web service which the customers use by inserting an external JavaScript (hosted on my servers). Recently, due to server outage - the external JavaScript became unavailable and my customers' websites came to a crawl as browser didn't load rest of the website until it loaded the JS (it goes into header of the websites).

I am trying to work out methods so that customers' website don't slow down even if my server goes down and for that I wanted to simulate a condition where the my server isn't responding. Note that if I specify a wrong URL, browser won't load the JS but in case URL is right and server isn't responding, browser will stall loading rest of the page. I want to simulate the last case. Any ideas how can I go about it?

PS: On server side, I am using the LAMP stack.

+4  A: 

Create a script that sleeps for a configurably long time

Something like

<?php
$how_long = $_GET['seconds'];
sleep($how_long);
echo "alert('Finished sleeping!');";
?>

Then you just access this script instead, for example by putting this in your HTML code <script src="http://example.com/hang_for.php?seconds=3600" />. That would sleep for an hour. There will be another timeouts that'll trigger first configured in php.ini, but that's exactly what you want to test, no?

Vinko Vrsalovic
+1  A: 

If the "P" in your LAMP is PHP, you could use the sleep function (documented here). Then, have your test page load your PHP script as the source of your Javascript to see what happens.

Jacob
A: 

Did you try looping back the server into itself (or any other HTTP server w/o the webservice on)?

Manrico Corazzi
+1  A: 

Unplug the server. Having no power makes a server unresponsive...

David Oneill
Better to issue a stop command to the webserver...
Vinko Vrsalovic
He wants to *simulate* it. Unplugging it *actually* makes it non-responsive.
graham.reeds
A: 

unplugging is pretty drastic, the off-button should do.

Neomusashi