WSF/PHP Services Performance test with WSDL Caching

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 ‘SIG’ or ‘Signature’ 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.

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.

The complete source codes used for the test can be found from here.

Here is a part of the service script I used. It is a simple echo service that echo a string.

	// create service in WSDL mode
	$service = new WSService(array ("wsdl" =>"echo.wsdl",
			"cacheWSDL" => false, // By default cache WSDL is true
			"actions" => $actions,
			"operations" => $operations));

	// getting the start_time
	$start_time = microtime(true);

	// process client requests and reply 

	// getting the end time
	$end_time = microtime(true);

	// getting the time difference
	$time_diff = $end_time - $start_time;


You can see in there I have set the “cacheWSDL” to false and log the time taken by the $service->reply() function. Later I have set the “cacheWSDL” to true and measure the time again for the comparison with earlier values.

I have written a client to invoke the service 10 times. And I’m going to measure the time taken do the client request in there.

	    for($i = 1; $i <= 10; $i ++) {
		// create client in WSDL mode
		$client = new WSClient(array ("wsdl" =>"echo.wsdl"));

		// get proxy object reference form client 
		$proxy = $client->getProxy();

		// create input object and set values
		//TODO: fill $input with (data type: string) data to match your business logic
		$input = "Hello World";

		// getting the start_time
		$start_time = microtime(true);

		// call the operation
		$response = $proxy->myEcho($input);
		//TODO: Implement business logic to consume $response, which is of type string

		// getting the end time
		$end_time = microtime(true);

		// getting the time difference
		$time_diff = $end_time - $start_time;


		echo $response."</br>";


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.

Without WSDL Caching With WSDL Caching
WSClient Operation invocation
WSService reply
WSClient Operation invocation
WSService reply
0.11091995239258 0.074313163757324 0.15158987045288 0.11872982978821
0.082005977630615 0.06772780418396 0.046205997467041 0.035470008850098
0.082638025283813 0.072394132614136 0.044647932052612 0.028353929519653
0.079883098602295 0.06883692741394 0.037378072738647 0.026839017868042
0.082012176513672 0.068314790725708 0.046517133712769 0.035148859024048
0.074619054794312 0.063674211502075 0.041852951049805 0.027253866195679
0.084127187728882 0.071602821350098 0.041593074798584 0.027820825576782
0.081571102142334 0.066971063613892 0.057910919189453 0.038385152816772
0.087567090988159 0.073211193084717 0.043420076370239 0.02738094329834
0.078658103942871 0.064589977264404 0.050504922866821 0.037022113800049

If you obvious these values you will figure out when you don’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.

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.

Response Time With and Without WSDL Caching

Response Time With and Without WSDL Caching

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.:)

This entry was posted in perfomance test, WSDL, wsf/php, wso2 and tagged , , , , , , , . Bookmark the permalink.

8 Responses to WSF/PHP Services Performance test with WSDL Caching

  1. Fierfeu says:

    Thanks for this very interesting study.

    I just have one question about the cache property which is not describe in the current documentation WSF/PHP !

    which versionof WSF/PHP are you using ?


  2. dimuthu says:

    It is wsf/php 2.0 I was talking about. But I think it is better you get the nightly build of wsf/php as it has more improvements


  3. Ben says:

    Hi Dimuthu,

    I’ve tried building the nightly build, but am getting errors, is this normal?
    ../../../include/platforms/unix/axutil_unix.h:125: error: syntax error before ‘__useconds’

    Thanks. Ben

  4. dimuthu says:

    Not really?
    what is the
    1 GCC version
    2 OS and version
    you are using?

  5. I got the error
    axutil_unix.h:125: error: syntax error before ‘__useconds’ when I tried to build for OS X 10.5.
    Are there any pointers to do something on this end.


  6. dimuthu says:

    Hi Sanjay,
    Well, I don’t have OS X installation here. But looking at the code, the problem occurs at the line,

    extern int usleep (__useconds_t __useconds);

    When I checked the unistd.h in my ubuntu linux machine, I found the function is declared with the same signature. I guess in your OS it has some other typedefs as function arguments. If you can find such function and replace the above line in axutil_unix.h probably you can get it compiled.


  7. Eric says:

    The presence of that usleep prototype is bogus: it’s a linuxism that shouldn’t be in axutil_unix.h. The prototype is present in unistd.h, so I don’t know why it was added to the axis header

  8. dimuthu says:

    Hi Eric,

    And yea it is linuxist. Probably OS X should have separate platform directory?. If you have a better solution please raise a jira on this in Axis2 project.


Leave a Reply

Your email address will not be published. Required fields are marked *