<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Dimuthu's Blog &#187; perfomance test</title>
	<atom:link href="http://www.dimuthu.org/catagory/perfomance-test/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.dimuthu.org</link>
	<description>Waiting for your comments</description>
	<lastBuildDate>Wed, 07 Jul 2010 12:42:52 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
<image>
  <link>http://www.dimuthu.org</link>
  <url>http://www.dimuthu.org/favicon.ico</url>
  <title>Dimuthu's Blog</title>
</image>
		<item>
		<title>WSF/PHP Services Performance test with WSDL Caching</title>
		<link>http://www.dimuthu.org/blog/2008/10/28/wsfphp-services-performance-test-with-wsdl-caching/</link>
		<comments>http://www.dimuthu.org/blog/2008/10/28/wsfphp-services-performance-test-with-wsdl-caching/#comments</comments>
		<pubDate>Tue, 28 Oct 2008 12:33:48 +0000</pubDate>
		<dc:creator>dimuthu</dc:creator>
				<category><![CDATA[WSDL]]></category>
		<category><![CDATA[perfomance test]]></category>
		<category><![CDATA[wsf/php]]></category>
		<category><![CDATA[wso2]]></category>
		<category><![CDATA[cacheWSDL]]></category>
		<category><![CDATA[optimization]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[response time]]></category>
		<category><![CDATA[test]]></category>
		<category><![CDATA[WSDL Caching]]></category>
		<category><![CDATA[wsdl mode]]></category>

		<guid isPermaLink="false">http://www.dimuthu.org/?p=547</guid>
		<description><![CDATA[WSDL Caching is first introduced with the WSF/PHP 2.0.0 release to optimize the response time of PHP web services. In WSDL Caching WSF/PHP keeps an intermediate XML model which is generated from the WSDL in memory. This intermediate model which we call as &#8216;SIG&#8217; or &#8216;Signature&#8217; model is generated at the first request to the [...]]]></description>
			<content:encoded><![CDATA[<p>WSDL Caching is first introduced with the <a href="http://wso2.org/projects/wsf/php">WSF/PHP 2.0.0</a> release to optimize the response time of PHP web services. In WSDL Caching WSF/PHP keeps an intermediate XML model which is generated from the WSDL in memory. This intermediate model which we call as &#8216;SIG&#8217; or &#8216;Signature&#8217; model is generated at the first request to the service. This SIG can be generated using an XSLT template from any WSDL 2.0. So if you provide a WSDL version 1.1, WSF/PHP first convert it to a WSDL 2.0 using another XSLT template and then generate the SIG model. So in generally when WSDL caching is used it avoids two XSLT parses and hence optimize the response time significantly.</p>
<p>In this blog, I will show you a result of some performance tests I did to measure the response time of a service with and without WSDL Caching.</p>
<p>The complete source codes used for the test can be found from <a href="http://downloads.dimuthu.org/codes/wsfphp/wsdl_caching_test.zip">here</a>.</p>
<p>Here is a part of the service script I used. It is a simple echo service that echo a string.</p>
<pre class="php">	<span style="font-style: italic; color: #808080;">// create service in WSDL mode</span>
	<span style="color: #0000ff;">$service</span> = <span style="font-weight: bold; color: #000000;">new</span> WSService<span style="color: #66cc66;">(</span><a href="http://www.php.net/array"><span style="color: #000066;">array</span></a> <span style="color: #66cc66;">(</span><span style="color: #ff0000;">"wsdl"</span> =&gt;<span style="color: #ff0000;">"echo.wsdl"</span>,
			<strong><span style="color: #ff0000;">"cacheWSDL"</span> =&gt; <span style="font-weight: bold; color: #000000;">false</span>, <span style="font-style: italic; color: #808080;">// By default cache WSDL is true</span></strong>
			<span style="color: #ff0000;">"actions"</span> =&gt; <span style="color: #0000ff;">$actions</span>,
			<span style="color: #ff0000;">"operations"</span> =&gt; <span style="color: #0000ff;">$operations</span><span style="color: #66cc66;">)</span><span style="color: #66cc66;">)</span>;

	<span style="font-style: italic; color: #808080;">// getting the start_time</span>
	<span style="color: #0000ff;">$start_time</span> = <a href="http://www.php.net/microtime"><span style="color: #000066;">microtime</span></a><span style="color: #66cc66;">(</span><span style="font-weight: bold; color: #000000;">true</span><span style="color: #66cc66;">)</span>;

	<span style="font-style: italic; color: #808080;">// process client requests and reply </span>
	<span style="color: #0000ff;">$service</span>-&gt;<span style="color: #006600;">reply</span><span style="color: #66cc66;">(</span><span style="color: #66cc66;">)</span>;

	<span style="font-style: italic; color: #808080;">// getting the end time</span>
	<span style="color: #0000ff;">$end_time</span> = <a href="http://www.php.net/microtime"><span style="color: #000066;">microtime</span></a><span style="color: #66cc66;">(</span><span style="font-weight: bold; color: #000000;">true</span><span style="color: #66cc66;">)</span>;

	<span style="font-style: italic; color: #808080;">// getting the time difference</span>
	<span style="color: #0000ff;">$time_diff</span> = <span style="color: #0000ff;">$end_time</span> - <span style="color: #0000ff;">$start_time</span>;

	logme<span style="color: #66cc66;">(</span><span style="color: #0000ff;">$time_diff</span><span style="color: #66cc66;">)</span>;</pre>
<p>You can see in there I have set the &#8220;cacheWSDL&#8221; to false and log the time taken by the $service-&gt;reply() function. Later I have set the &#8220;cacheWSDL&#8221; to true and measure the time again for the comparison with earlier values.</p>
<p>I have written a client to invoke the service 10 times. And I&#8217;m going to measure the time taken do the client request in there.</p>
<pre class="php">	    <span style="color: #b1b100;">for</span><span style="color: #66cc66;">(</span><span style="color: #0000ff;">$i</span> = <span style="color: #cc66cc;">1</span>; <span style="color: #0000ff;">$i</span> &lt;= <span style="color: #cc66cc;">10</span>; <span style="color: #0000ff;">$i</span> ++<span style="color: #66cc66;">)</span> <span style="color: #66cc66;">{</span>
		<span style="font-style: italic; color: #808080;">// create client in WSDL mode</span>
		<span style="color: #0000ff;">$client</span> = <span style="font-weight: bold; color: #000000;">new</span> WSClient<span style="color: #66cc66;">(</span><a href="http://www.php.net/array"><span style="color: #000066;">array</span></a> <span style="color: #66cc66;">(</span><span style="color: #ff0000;">"wsdl"</span> =&gt;<span style="color: #ff0000;">"echo.wsdl"</span><span style="color: #66cc66;">)</span><span style="color: #66cc66;">)</span>;

		<span style="font-style: italic; color: #808080;">// get proxy object reference form client </span>
		<span style="color: #0000ff;">$proxy</span> = <span style="color: #0000ff;">$client</span>-&gt;<span style="color: #006600;">getProxy</span><span style="color: #66cc66;">(</span><span style="color: #66cc66;">)</span>;

		<span style="font-style: italic; color: #808080;">// create input object and set values</span>
		<span style="font-style: italic; color: #808080;">//TODO: fill $input with (data type: string) data to match your business logic</span>
		<span style="color: #0000ff;">$input</span> = <span style="color: #ff0000;">"Hello World"</span>;

		<span style="font-style: italic; color: #808080;">// getting the start_time</span>
		<span style="color: #0000ff;">$start_time</span> = <a href="http://www.php.net/microtime"><span style="color: #000066;">microtime</span></a><span style="color: #66cc66;">(</span><span style="font-weight: bold; color: #000000;">true</span><span style="color: #66cc66;">)</span>;

		<span style="font-style: italic; color: #808080;">// call the operation</span>
		<span style="color: #0000ff;">$response</span> = <span style="color: #0000ff;">$proxy</span>-&gt;<span style="color: #006600;">myEcho</span><span style="color: #66cc66;">(</span><span style="color: #0000ff;">$input</span><span style="color: #66cc66;">)</span>;
		<span style="font-style: italic; color: #808080;">//TODO: Implement business logic to consume $response, which is of type string</span>

		<span style="font-style: italic; color: #808080;">// getting the end time</span>
		<span style="color: #0000ff;">$end_time</span> = <a href="http://www.php.net/microtime"><span style="color: #000066;">microtime</span></a><span style="color: #66cc66;">(</span><span style="font-weight: bold; color: #000000;">true</span><span style="color: #66cc66;">)</span>;

		<span style="font-style: italic; color: #808080;">// getting the time difference</span>
		<span style="color: #0000ff;">$time_diff</span> = <span style="color: #0000ff;">$end_time</span> - <span style="color: #0000ff;">$start_time</span>;

		logme<span style="color: #66cc66;">(</span><span style="color: #0000ff;">$time_diff</span><span style="color: #66cc66;">)</span>;

		<a href="http://www.php.net/echo"><span style="color: #000066;">echo</span></a> <span style="color: #0000ff;">$response</span>.<span style="color: #ff0000;">"&lt;/br&gt;"</span>;

	    <span style="color: #66cc66;">}</span></pre>
<p>Then I have measured the time taken to first 10 request for both WSDL caching on and off scenarios just after starting the Apache server.</p>
<table border="1">
<tbody>
<tr style="background: #dddddd">
<td colspan="2">Without WSDL Caching</td>
<td colspan="2">With WSDL Caching</td>
</tr>
<tr style="background: #dddddd">
<td>WSClient Operation invocation<br />
$client-&gt;myEcho($input)</td>
<td>WSService reply<br />
$service-&gt;reply()</td>
<td>WSClient Operation invocation<br />
$client-&gt;myEcho($input)</td>
<td>WSService reply<br />
$service-&gt;reply()</td>
</tr>
<tr>
<td>0.11091995239258</td>
<td>0.074313163757324</td>
<td>0.15158987045288</td>
<td>0.11872982978821</td>
</tr>
<tr>
<td>0.082005977630615</td>
<td>0.06772780418396</td>
<td>0.046205997467041</td>
<td>0.035470008850098</td>
</tr>
<tr>
<td>0.082638025283813</td>
<td>0.072394132614136</td>
<td>0.044647932052612</td>
<td>0.028353929519653</td>
</tr>
<tr>
<td>0.079883098602295</td>
<td>0.06883692741394</td>
<td>0.037378072738647</td>
<td>0.026839017868042</td>
</tr>
<tr>
<td>0.082012176513672</td>
<td>0.068314790725708</td>
<td>0.046517133712769</td>
<td>0.035148859024048</td>
</tr>
<tr>
<td>0.074619054794312</td>
<td>0.063674211502075</td>
<td>0.041852951049805</td>
<td>0.027253866195679</td>
</tr>
<tr>
<td>0.084127187728882</td>
<td>0.071602821350098</td>
<td>0.041593074798584</td>
<td>0.027820825576782</td>
</tr>
<tr>
<td>0.081571102142334</td>
<td>0.066971063613892</td>
<td>0.057910919189453</td>
<td>0.038385152816772</td>
</tr>
<tr>
<td>0.087567090988159</td>
<td>0.073211193084717</td>
<td>0.043420076370239</td>
<td>0.02738094329834</td>
</tr>
<tr>
<td>0.078658103942871</td>
<td>0.064589977264404</td>
<td>0.050504922866821</td>
<td>0.037022113800049</td>
</tr>
</tbody>
</table>
<p>If you obvious these values you will figure out when you don&#8217;t use WSDL caching it takes same amount of time to server each request. But when you turn on WSDL caching it takes a little more time at the very first request, but the subsequent requests take very low values.</p>
<p>Here is the chart for the above Data, See the Green and White lines corresponding to the WSDL caching turn on, have taken low values. In average we can observe a 50% reduction in server response time with the WSDL caching.</p>
<div id="attachment_552" class="wp-caption aligncenter" style="width: 510px"><a href="http://www.dimuthu.org/wp-content/uploads/2008/10/chart.jpg"><img class="size-full wp-image-552" title="Response Time With and Without WSDL Caching" src="http://www.dimuthu.org/wp-content/uploads/2008/10/chart.jpg" alt="Response Time With and Without WSDL Caching" width="500" height="341" /></a><p class="wp-caption-text">Response Time With and Without WSDL Caching</p></div>
<p>This result is for a very simple WSDL which only had an echo operation. When the WSDL get more complex and contain lot of wsdl/schema includes and imports, we can expect more optimization due to the WSDL caching. We will check how the complexity of the WSDL affect the performance in a later blog post.:)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dimuthu.org/blog/2008/10/28/wsfphp-services-performance-test-with-wsdl-caching/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
	</channel>
</rss>
