开发者

How can I simulate a non-responding server?

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 a开发者_JS百科nd 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.


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?


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.


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


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


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜