Search code examples
performancewcf.net-4.5iis-8windows-server-2012-r2

WCF service call getting queued. Sometimes returning a 500 internal server error


I have a WCF (.NET 4.5.2) application hosted on IIS 8.5 Windows 2012 R2 machine which calls to another WCF (.NET 4.5.2) application hosted on another IIS 8.5 Windows 2012 R2 machine. Problem is that when there are bulk calls (Let say 200+) my requests seems to be queuing.

Any idea what particular improvement I do? Both Machines have 4 cores and 4 GB ram

At the moment I have tried with following tweak in machine config

<!-- <processModel autoConfig="true" /> -->
    <processModel autoConfig="false" maxWorkerThreads="1400" maxIoThreads="1400" minWorkerThreads="10" />

One problem i also see randomly is that I get 500 internal error. Looks like calls never reaches the second server. Full error trace is

The content type text/html of the response message does not match the content type of the binding (text/xml; charset=utf-8). If using a custom encoder, be sure that the IsContentTypeSupported method is implemented properly. The first 192 bytes of the response were: '<html>
<head><title>500 Internal Server Error</title></head>
<body bgcolor="white">
<center><h1>500 Internal Server Error</h1></center>
<hr><center>nginx/1.8.0</center>
</body>
</html>
'.
System.ServiceModel.ProtocolException: The content type text/html of the response message does not match the content type of the binding (text/xml; charset=utf-8). If using a custom encoder, be sure that the IsContentTypeSupported method is implemented properly. The first 192 bytes of the response were: '<html>
<head><title>500 Internal Server Error</title></head>
<body bgcolor="white">
<center><h1>500 Internal Server Error</h1></center>
<hr><center>nginx/1.8.0</center>
</body>
</html>
'. ---> System.Net.WebException: The remote server returned an error: (500) Internal Server Error.
   at System.Net.HttpWebRequest.GetResponse()
   at System.ServiceModel.Channels.HttpChannelFactory`1.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
   --- End of inner exception stack trace ---

Solution

  • The log4net db logging was found to be the culprit. DB logging was happening one by one so I have increased the bufferSize property of log4net to 10.