title: PHP Soap Client call CPU usage
body: <p>I'm struggling with this issue for several months now, so I've decided to ask for help. On our current project we use several Web-Services to communicate with external servers. One of them handles big amount of data, and soap call takes quite long time. Some methods invocations take up to 5-10s.</p>
  
  <p>We can deal with such time, the problem is located elsewhere. We're using pretty strong machine to host our application (dedicated, 6 xenon processors, 16 gb ram memory). When we invoke external WS, and server listens for response, CPU usage peaks are huge. </p>
  
  <p>I've tested it on some weaker machine, and it looks that such process can use up to 100% of single core usage, which obviously affects performance greatly.</p>
  
  <p>Our application is based on PHP Zend-Framework (version 1). As Soap client we use Zend_Soap_Client.</p>
  
  <p>I'd appreciate any suggestions how to optimise this.
  Thank you in advance</p>
  
  <p>EDIT:</p>
  
  <ol>
  <li><p>Part of code - I've completly forgot that we've implemented modification that replaces php SoapClient request with Curl to handle timeouts (altough problem occurs in both approaches). Here's part of our client:</p>
  
  <pre><code>try {
  
  $this-&gt;client = new SoapExt_Client($this-&gt;config-&gt;wsdl,
                array(
                    'cache_wsdl' =&gt; WSDL_CACHE_BOTH,
                    'encoding' =&gt; $this-&gt;config-&gt;encoding,
                    'soap_version' =&gt; SOAP_1_1,
                    'classmap' =&gt; array(
                        [...]
                    ),
                    'features' =&gt; SOAP_SINGLE_ELEMENT_ARRAYS
                )
  );
   $this-&gt;client-&gt;__setTimeout((int) $this-&gt;config-&gt;timeout);
  } catch (Exception $exc) {
  throw new My_Exception_System(My_Codes::ERROR_WS_CONNECTION_FAILED, array(__CLASS__));
  }
  </code></pre></li>
  </ol>
  
  <p>And method invocation:</p>
  
  <pre><code>$result = $this-&gt;client-&gt;$methodName($params);
  </code></pre>
  
  <p>So basicly it's a simple Soap Call. The CPU usage spikes occur while script is waiting for remote servers to repply.</p>
  
  <ol>
  <li>Webserver is hosted on .NET WCF Service. Our, client app is hosted on PHP (tested on Apache and IIS).</li>
  <li>No, I haven't used any debuggin tool. All above remarks are based on our logs and performance monitoring.</li>
  <li>Yes there are several imports in WSDL.</li>
  <li>On second thought - part about big amount of data could be missleading. Data we're receiving doesn't extend 50 KB. Moreover, operations which take the longest amount of time don't return large amounts of data, it's rather issue of processing time of the webserver. </li>
  </ol>