2

My company is currently transitioning from traditional ASMX webservices to WCF webservices, because we need the improved handling of complex types available with WCF.

Whilst investigating performance issues with a web page, I have identified that the biggest (by some margin) performance sinkhole is the initial connection to the WCF service. When I say initial, I mean the following bit of code, every time it is called, a page refresh is enough to get a slow connection:

$client = new SoapClient("<address-to-webservice>",
array('features' => SOAP_SINGLE_ELEMENT_ARRAYS));

Subsequent calls to the methods in this webservice are quick, however the connection is inexplicably slow.

On the same page there is a connection to an ASMX service that is hosted on the same server, which connects much much quicker.

Connection to WCF Webservice took 1.6509809494019 seconds //(this is just calling new SoapClient)
Connection to ASMX Webservice took 0.24430394172668 seconds

Calling ASMX->Method
ASMX->Method returned in 0.011564970016479 seconds

Calling WCF->Method1
WCF->Method1 returned in 0.011118173599243 seconds

Calling WCF->Method2
WCF->Method2 returned in 0.0038959980010986 seconds

Calling WCF->Method3
WCF->Method3 returned in 0.0041651725769043 seconds

This is running on an internal network, and obviously connecting from outside is even slower. As you can see the WCF Webservice connection is considerably slower.

Is there a way to improve performance (considerably) when connecting to the WCF webservice?

UPDATE:

Some information about the WCF Client. Hosted on IIS 7, Windows Server 2008. Using BasicHttpBinding (as the PHP SoapClient doesn't support the more complex wsHttpBinding). The connection is using ssl.

Additionally, when connecting via WCFStorm the connection is much faster, leading me to believe the issue is perhaps with the PHP SoapClient.

lxalln
  • 930
  • 11
  • 29
  • You'll need to put more detailed configuration information about the WCF service like the binding (i.e. HTTP based binding, netTcpBinding or something else) and how is it hosted (i.e Windows NT service, IIS 7.5 or another host application) to get a good answer. Also, you should wire up the WCF service with the built-in diagnostics for tracing activity because all you are presenting is the total round-trip time. The actual bottleneck may not necessarily be the WCF service. Finally, WCF is a "heavier weight" framework than ASMX so it will generally have more start up costs. – Sixto Saez May 17 '11 at 17:36
  • When I connect to the same service using WCFStorm it is much quicker, so based on that, I'm assuming the problem is more to do with the PHP SoapClient than the WCF Service, but I'll add some more information about the WCF config too. – lxalln May 17 '11 at 17:49
  • See also: http://stackoverflow.com/questions/5944067/php-soapclient-constructor-is-very-slow-takes-3-minutes I think it is probably a SoapClient issue. – CodingWithSpike May 17 '11 at 18:20

2 Answers2

1

Just a guess based on your WCFStorm comment in the question, it could be that the WSDL generated by the ASMX version may be easier to parse than the WCF version of the service. I don't know if the PHP SoapClient dynamically creates the proxy from the WSDL but if the WSDL generated by ASMX vs WCF is significantly different then that may cause the initial bottleneck.

Sixto Saez
  • 12,610
  • 5
  • 43
  • 51
1

Our problem has been resolved by fixing the location of soap.wsdl_cache_dir in php.ini.

Our websites were hosted and developed on Windows machines, so the default directory of '/tmp' didn't work. Changing this to C:\Windows\Temp has meant although the initial connection is still slow, all subsequent requests are fast.

We will now look into using a more common solution of a warm-up script.

lxalln
  • 930
  • 11
  • 29