Click here to Skip to main content
14,689,406 members
Articles » Platforms, Frameworks & Libraries » Windows Communication Foundation » General
Posted 29 Sep 2010

Tagged as


15 bookmarked

WCF First Call Slow

Rate me:
Please Sign up or sign in to vote.
4.67/5 (6 votes)
29 Sep 2010CPOL
WCF slow to respond

WCF Slow to Start

A week or so ago we got reports that our production web application was slow. With further testing, we realized that application's performance slowdown was caused by one particular WCF call taking 15 - 30 seconds. The slowness was not consistent either! Sometimes it was less than a second, and the next call it would hit 30 seconds! We think we have the problem fixed - it was a combination of IIS host service startup costs, and attempting to hit a local proxy on first call.

Researching the issue lead me to realize this type of issue is widespread, so here are some tips for others dealing with the same issue:

This first thing you can do is setup the service trace viewer on your web server by modifying the web.config or app.config of your service host. Add full tracing, test your service, and review the resulting log files to see where the slowdown is occuring. Too many times I have been burned by assuming I knew where the peformance bottleneck is and fixing non-issues. So measure twice before you start trying to fix a performance problem.

Service trace viewer is included with the MS Windows SDK. Once you have it, you can easily copy the executable wherever you need it.[^]

Tip - sort the WCF calls in Service Trace Viewer by call time. Then you can easily spot the bottlenecks.

IIS Startup Time

1) If you are hosting your WCF service in IIS, there is a high cost for the first call. On the first call to your WCF service, IIS must compile your service. Then IIS must construct and start the service host.

Furthermore, IIS automatically stops services that are idle for a certain period of time. The default idle timeout is 20 minutes. Keep in mind if you have a load balancer, then each server will timeout independently, which can cause strange behavior as you jump between servers.


1) I have seen a couple of references to this warmup template which basically hits your server to cause IIS to compile and start your service. Cannot say that I have tried it:[^]
2) IIS has an idle timeout. So once your service has been hit once, and is running, if it doesn't have activity for some period of time, IIS will automatically stop it. You can alter this timeout, to make your service less likely to idle, or turn off the idle timeout feature entirely:[^]


Do not use default HTTP proxy

Set useDefaultProxy="false" in your client http binding to tell WCF not to use the default proxy on your client computer:[^]
When you have useDefaultProxy="true" you are telling WCF to pick the proxy settings from IE.

Use XML Serializer

You can improve the startup times of a WCF Client by generating XmlSerializer serialization code:[^]

Netbios on TCP

There are repeated references to high costs for initializing app domains where the host server has been configured to use netbios over TCP. E.g.[^] The resolution is to disable Netbios over tcp:[^]

Publisher Evidence - Network Call

When IIS initializes an application pool, it may verify that an assembly is legitimate using publisher evidence. According to the docs, this is no longer enabled by default in .net 4.[^]

WCF Security

Make sure your WCF client security settings are consistent with your service. Do not enable security on your client that is not used by your service.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Jon Paugh
United States United States
No Biography provided

Comments and Discussions

GeneralAWESOME! Pin
Member 816766514-Nov-13 4:33
MemberMember 816766514-Nov-13 4:33 
QuestionIIS Idle Time Pin
fedelexteam3-Oct-13 4:28
Memberfedelexteam3-Oct-13 4:28 
QuestionuseDefaultWebProxy="false" / Thank you! Pin
giandeibrughi31-Aug-12 5:32
Membergiandeibrughi31-Aug-12 5:32 
QuestionPerfect - the WPAD / automatic proxy settings was slowing things down :) Pin
OddArne7-Sep-11 3:03
MemberOddArne7-Sep-11 3:03 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.