我們目前正在考慮在一個依賴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