views:

139

answers:

5

I have a web service running and I consume it from my desk application that is written on Compact Framework.

It takes 13 seconds to retrieve 8 results which is kinda slow. I also expect to be retrieving more results in the future. The database query runs fast.

Two questions: how do I detect where the speed slow down occurs? Do I put timers in the Web services code?

I would like to detect whether it is the network or the application code. This is my first exposure to web services in a real environment so please bear with me.

i used asp.net 2.0 and c# to write a simple web service.

A: 

Your already on the right track of adding event logging, and include timers in them. Note, doing so will add to the over all time it takes, so you'll want to remove them after you track down the culprit. Also look into running the same webservice call multiple-times without re-initiating the connection, that may be cause as well.

-Jay

Jay
what do you mean without re-initiating the connection? i haven't put timers in the web service yet. The only thing that comes to mind is put the timers in the web service and record it in the log files on the web server. Are there any other methods that devs use? If not, I will just go with that. Also, is running the web service asynchronously (with BeginFunctionName) better?
gnomixa
what i noticed that when I call it the first time, it takes 13 seconds, but when i call it subsequently with different input parameters (same web method), it's lightning fast. Is there any way that the connection with the web service has a time out parameter...why would it take so long the first time but super fast after?
gnomixa
what this tells me, is that the bulk of the time it takes for your first WS call is initialization "Stuff" ... such as the WS application it self starting up, the consuming application establishing a connection to the WSDL, and making the appropriate connections. It sounds like you may want to load the WS at your application boot time (in a seperate thread maybe) so when your ready to make your actual calls, it should be speedy.
Jay
A: 

A starting point is to profile your web service to see where the delay is comming from

Did you know the CLR Profiler? There are some tools you can use to see what is happening

http://msdn.microsoft.com/en-us/library/ms998579.aspx

Doritos
A: 

The database connectivity from your service to the DB could be a possible cause for slowdown. Adding timers should do the trick. If the code isnt too huge, you can look at the coding constructs to come up with an informed decision of where exactly things can be slow. Then add the timers. You would get a fair idea of where things are slowing down.

Thiyagaraj
+1  A: 

Another good profiler is the EQATEC Profiler. I did a write up on it here: http://elegantcode.com/2009/07/02/eqatec-profiler-and-net-cf-profiling-and-regular-net/

And it works find for .net CF projects. But this will allow you to see if there performance issues in unexpected places.

Chris Brandsma
This is a good, free profiling recommendation. Takes a bit of tinkering (in my experience), but provides very good results.
Ty
A: 

Two biggest pain points are going to be instantiating the web service reference and transferring all the data over the network. Pending anything turning up where some obvious blunder was made, I would look at ways of reducing the size of your xml and ways of better handling your web service reference.

All I know about the compact framework is that it is a pain to work in. I've worked on a number of web projects though and profiling your server, putting in logging to record the time taken will be helpful. If all the time is being taking post server response, however, it won't do much more than prove your server is working quickly.

SoapUI is a fantastic java application for consuming web services. It has a lot of functionality, including time metrics. I would start with that and see how long it takes to consume the same thing your client would be. Failing issues there, start with what I recommended above.

Ty