Adding Latency to a Web Application

I want to slow down my application by adding latency for ajax requests. I have two options: do it in javascript and do it server side. With javascript, I could easily add setTimeout to my requests, but there are about 30 different requests, and I am wondering if there is a better way with less code.

I want to slow down server side ajax requests. What is the best way to do this? I use about 25 different asmx web services (will be converted to wcf soon), and I am wondering how to make sure that all requests have 1000 ms of delay.

My goal is to change as little code as possible so that I can enable / disable this feature by changing as little as possible.

Thanks for your suggestions.

In case you are wondering why: I am running my local machine. I am going to have a user testing session and I need to simulate real ajax requests. Without delay, the ajax request happens almost instantly.

+3
source share
4 answers

You can add

System.Threading.Thread.Sleep(1000)

in OnRequestBegin-handler or where ever you can intercept a request before doing the actual work.

+4
source

If you use jquery to call ajax, just go to the jquery code file and add latency there. Will this work?

Look for this line in the jquery main file:

ajax: function( url, options ) {

Add this code immediately after:

var ms = 1000 //wait time in milliseconds
ms += new Date().getTime();
while (new Date() < ms) { }

ms - number of milliseconds waiting

0
source

, ajax. , - .

0

- http , .

Since I know Perl is better, I would use something like http://metacpan.org/pod/HTTP::Proxy and add a filter that did nothing, but wait a second.

0
source

All Articles