连接到WCF Web服务的速度令人费解

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.

doutang6819
doutang6819 另请参阅:stackoverflow.com/questions/5944067/...我认为这可能是一个SoapClient问题。
9 年多之前 回复
doupiao1893
doupiao1893 当我使用WCFStorm连接到相同的服务时,它更快,所以基于此,我假设问题更多的是与PHPSoapClient而不是WCF服务,但我将添加一些有关WCF配置的更多信息太。
9 年多之前 回复
dongzhi1949
dongzhi1949 您需要提供有关WCF服务的更详细的配置信息,如绑定(即基于HTTP的绑定,netTcpBinding或其他)以及如何托管(即WindowsNT服务,IIS7.5或其他主机应用程序)以获得良好回答。此外,您应该使用内置的跟踪活动诊断程序连接WCF服务,因为您要呈现的是总往返时间。实际的瓶颈可能不一定是WCF服务。最后,WCF是一个比ASMX更“重量级”的框架,因此通常会有更多的启动成本。
9 年多之前 回复

2个回答



我们的问题已通过在php.ini中修复 soap.wsdl_cache_dir </ code>的位置来解决。</ p >

我们的网站是在Windows机器上托管和开发的,因此默认目录'/ tmp'不起作用。 将此更改为C:\ Windows \ Temp意味着虽然初始连接仍然很慢,但所有后续请求都很快。</ p>

我们现在将研究使用更常见的温暖解决方案。 脚本。</ p>
</ div>

展开原文

原文

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.



根据你在问题中的WCFStorm评论猜测,可能是由ASMX版本生成的WSDL可能更容易解析 比WCF版本的服务。 我不知道PHP SoapClient是否从WSDL动态创建代理,但如果ASMX与WCF生成的WSDL明显不同,那么可能会导致初始瓶颈。</ p>
</ div>

展开原文

原文

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.

立即提问