我们目前正在考虑在一个依赖Soap Web服务的网站上调整性能。但是......我们的服务器位于比利时,我们连接的网络服务位于旧金山,因此至少可以说是一个长途连接。加快肥皂供电网站的速度
我们的网站采用PHP驱动,使用PHP内置的SoapClient类。 平均而言,对web服务的调用需要0.7秒,而我们每页大约需要3-5个请求。所有可能的请求/响应缓存已经实现,所以我们现在正在寻找其他方法来提高连接速度。
这是实例化SoapClient的代码,我现在正在寻找的是提高单个请求速度的其他方式/方法。任何人有想法或建议?
private function _createClient()
{
try {
$wsdl = sprintf($this->config->wsUrl.'?wsdl', $this->wsdl);
$client = new SoapClient($wsdl, array(
'soap_version' => SOAP_1_1,
'encoding' => 'utf-8',
'connection_timeout' => 5,
'cache_wsdl' => 1,
'trace' => 1,
'features' => SOAP_SINGLE_ELEMENT_ARRAYS
));
$header_tags = array('username' => new SOAPVar($this->config->wsUsername, XSD_STRING, null, null, null, $this->ns),
'password' => new SOAPVar(md5($this->config->wsPassword), XSD_STRING, null, null, null, $this->ns));
$header_body = new SOAPVar($header_tags, SOAP_ENC_OBJECT);
$header = new SOAPHeader($this->ns, 'AuthHeaderElement', $header_body);
$client->__setSoapHeaders($header);
} catch (SoapFault $e){
controller('Error')->error($id.': Webservice connection error '.$e->getCode());
exit;
}
$this->client = $client;
return $this->client;
}
如果您无法将服务器移动到旧金山,您可以尝试移动比利时。我认为有一个python模块可以做到这一点。 – 2010-05-04 08:58:17