tags:

views:

166

answers:

3
+1  Q: 

WCF - Network Cost

Dear Devs

I have a wcf service deployed on IIS with basicHttpBinding and aspNetCompatibilityEnabled=true

I have a test client as well which invokes multiple service functions simultaneously. To check the performance of service call on client and server I calculated the Avg time it takes to complete a service request on client(in proxy code) and on server as well.

after a test of 8 hrs (server and client were on the same machine) i came to know that average response time on client is around 34ms where as the Avg execution time on server is around 3ms so the difference is 31ms.

I would like to know why every call is taking 31ms is it justified? and how can i reduce this?

EDIT: After Answer Post by "Marc Gravell"

  1. SSL Enabled within IIS no other security on WCF level
  2. Service perform minor database operation you can estimate operation cost by given 3ms average execution time. (if this is what you call payload)
  3. There is no Blob, no MTOM
  4. Send and Receive Messages are not big may be around 100 byte to 500 byte, Simple Message Contracts
  5. Please let me know if anything else required to diagnose this
  6. Actually i am more concerned about the cost of TCP Connection establishment if you can explain how WCF does the TCP connection job and if there is any difference in it against different bindings available
+1  A: 

What operations are you performing? i.e. what is the payload size? If you perform vast numbers of operations with very small payloads, then you will obviously suffer more from latency etc; however bandwidth can also be an issue with non-trivial payloads. If you are suffering from this, you could try a different serializer. Let me know if the payload size is a possible issue here, as there may be some options there.

Also; what security / streaming / etc options are you using? Message-based security is more expensive at both ends (compared to transport security), and IIRC blocks streaming as the entire message must be available in order to verify it. Similarly, if you are throwing blobs around you may benefit from enabling MTOM (which is posible over basic-http) and using the streaming APIs.

Marc Gravell
Edit Original Questions please check Thanks for Response anyways
Mubashar Ahmad
A: 

There are so many questions to be asked here. Marc started with a round of good questions but, ultimately, I imagine we won't be able to get enough info from you about your programs, the platform, and network to give you a complete answer online.

Were I in your situation, first thing I would do would be to conduct a bit of analysis to understand what's going on under the covers. Specifically, I'd use ProcMon to analyze system activities leading up to and including the network transmission to make sure I had the network time precise. Based upon these findings, I'd either dive deeper into what's going on the wire or use a .NET performance profiler to look at what operations on the stack are costing you the greatest amount of time.

Thomas Beck
+1  A: 

After a long research and test executions i came to the conclusion that it is happening due to the Thread Invocation time on server, As WCF uses I/O completion Ports(an efficient threading model. Detail here)

and you need to set the minimum concurrency requirements in the start of your server that may be done like follows

ThreadPool.SetMinThreads(100, 100);

Otherwise you will be suffer due to the default values of pool minimum size that is 2,2 and any new thread will require a cost of creation of thread (that every developer knows that is most costly process). By doing above Threadpool will maintain the at-least 100 thread ready to work and your service will rock.

As i have reduce the the waisted 31ms to 6ms.

Mubashar Ahmad