连接到 WCF Web Service 莫名其妙的慢 [英] Connecting to WCF Web Service is inexplicably slow

查看:38
本文介绍了连接到 WCF Web Service 莫名其妙的慢的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的公司目前正在从传统的 ASMX 网络服务过渡到 WCF 网络服务,因为我们需要改进对 WCF 可用的复杂类型的处理.

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

在调查网页的性能问题时,我发现最大的(在一定程度上)性能坑是与 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.

在同一页面上,有一个到托管在同一台服务器上的 ASMX 服务的连接,该服务的连接速度要快得多.

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

这是在内部网络上运行,显然从外部连接更慢.如您所见,WCF Web 服务连接速度相当慢.

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.

在连接到 WCF 网络服务时,有没有办法(显着)提高性能?

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

更新:

有关 WCF 客户端的一些信息.托管在 IIS 7、Windows Server 2008 上.使用 BasicHttpBinding(因为 PHP SoapClient 不支持更复杂的 wsHttpBinding).连接正在使用 ssl.

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.

此外,当通过 WCFStorm 连接时,连接速度要快得多,这让我相信问题可能出在 PHP SoapClient 上.

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

推荐答案

我们的问题已经通过修复 php.ini 中 soap.wsdl_cache_dir 的位置解决了.

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

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

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.

这篇关于连接到 WCF Web Service 莫名其妙的慢的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆