|
Subject:
|
Web Service first hit delay
|
|
Posted By:
|
michurin
|
Post Date:
|
7/1/2008 8:33:46 PM
|
Hi everybody,
Here is the question. I have win form appl (C#) witch accesses the web service (ASP.NET, C#), multiple instances of appl hast to be used on different machines, everything works but, during the first hit, doesn’t matter from witch machine, it takes about 25-30 sec to get an answer, then more machines trying to access it simultaneously then slower 4 – 5 machines will bring it to 40-45 sec, every following request is done in 5 sec, if client closes appl and starts it right back, so here is no problems with web service timeout because appl is started literally right after closing, again first request will take in about 40-45 sec and every following will take 5 sec. Web service do not indentifies the client in any way, its ready to answer to anybody who’ll call its method. As far as I know web service, as any other web appl, because of HTTP is stateless but it seems like web service remembers each instance of appl and rebuilds or constructs something every time new instance is calling it. So the question is what may cause this delay during first hit of web service and how I can decries this delay?
Thank you.
|
|
Reply By:
|
Old Pedant
|
Reply Date:
|
7/1/2008 8:47:41 PM
|
You don't say WHAT the web service is doing.
But just for example, if it is making some big SQL query and is returning lots of data, it could very well be that subsequent "hits" to the same service are finding that the query data has been cached by SQL Server (or even by the file system, if you are using Access DB). So just that, alone, could account for all of it.
It's also possible that the web server where this is running is heavily loaded with other tasks. So when this web service is first "hit", it needs to load many many resources (DLLs, espeically) that are not used by other things on the same server. That, too, can take quite a while on a fully loaded server.
Anyway, I don't think you gave us enough details to make more than guesses at the answer.
|
|
Reply By:
|
michurin
|
Reply Date:
|
7/1/2008 9:08:18 PM
|
Hi Old Pedant, First of all thank you for your response. Web Service is running DB2 Store proc using DB2 Connect and it does returns a lot of data about 300-600 kb but data every time is different so its cannot be cashed. Web server is not heavily loaded; we were monitoring memory and CPU use during the tests. I was logging the time needed to run the code inside the web service, simply by storing timestamp in variable when code starts its execution and a timestamp right before the return statement and writing it in the log file, and its show that it takes about 3 sec to execute all the code, in the same time I did the same thing in client appl saving timestamp right before calling the web service method and right after it and on the first run it show 40 sec, by merging both results from client and web service logs from the same client I can see that execution on web service is pretty much the same during first or any other call, may be on the first it’s a bit longer but on client side first call takes 40 sec all following much less, and as I sad before if client appl is closed and restarted again immediately after, the first run after restart will take again 40 sec and all following from the same instance of appl 5-10 sec. And another thing, just in case, initialization of web service like WebService WS = New WebService is done on win form load not in the event witch fires web service method.
Thank you.
|
|
Reply By:
|
gbianchi
|
Reply Date:
|
7/1/2008 10:03:46 PM
|
Insane idea, mmm, maybe the store procedure doesn't work ok?? You said that all the code YOU wrote run in 3 seconds, but remember that IIS has to handle an HTML back to the client.. maybe you have images that slow it down?? or some other things in your page??
HTH
Gonzalo
=========================================================== Read this if you want to know how to get a correct reply for your question: http://www.catb.org/~esr/faqs/smart-questions.html ^^Took that from dparsons signature and he Took that from planoie's profile =========================================================== My programs achieved a new certification (can you say the same?): WORKS ON MY MACHINE http://www.codinghorror.com/blog/archives/000818.html =========================================================== I know that CVS was evil, and now i got the proof: http://worsethanfailure.com/Articles/Classics-Week-I-Hate-You.aspx ===========================================================
|
|
Reply By:
|
michurin
|
Reply Date:
|
7/2/2008 8:17:03 AM
|
Hi gbianchi,
Thank you for your response, Store proc is working i am getting my response but slower then i need it too on the first hit of web service, another thing is that the client appl is Win Form appl not a web form so there is no web pages involved, and second as far as i know there is not HTML involved, web service returns XML.
Thank you
|
|
Reply By:
|
gbianchi
|
Reply Date:
|
7/2/2008 8:22:27 AM
|
You are right, my mistake, you are talking about a web service. Maybe your client is not working ok?? do you display the XML in any format?? what if you only call the webservice?? (without doing anything else)...
HTH
Gonzalo
=========================================================== Read this if you want to know how to get a correct reply for your question: http://www.catb.org/~esr/faqs/smart-questions.html ^^Took that from dparsons signature and he Took that from planoie's profile =========================================================== My programs achieved a new certification (can you say the same?): WORKS ON MY MACHINE http://www.codinghorror.com/blog/archives/000818.html =========================================================== I know that CVS was evil, and now i got the proof: http://worsethanfailure.com/Articles/Classics-Week-I-Hate-You.aspx ===========================================================
|
|
Reply By:
|
michurin
|
Reply Date:
|
7/2/2008 8:44:59 AM
|
I am logging every step on the client the same way as on the web service and the timestamps before the web service call and right after show that the web service call itself takes 40 sec on the first run, in the same time the execution of a code in web service takes 3 – 3.5 sec so I’ll guess that sending response back takes another 8 sec so here we are getting 11 – 15 sec and that exactly how long does it take to get the result during second or any other following request, the question is what takes another 30 sec during first request. ( This is not a timeout problem because client appl was closed and started back and time out is set for 20 min) Actually the main question is: Web Service is stateless but it looks like web service remember the each instance of the appl preloads some resources for this particular client and then holds them up for this particular client.
Thank you
|