X

Measuring Performance of Policy Code in WSIT -- First Steps

This week I have spent some time on measuring performance of our wspolicy implementation
and it's impact on overall performance of WSIT (http://wsit.dev.java.net/).
Nowadays -- after feature freeze -- we want to spend some cycles on performance improvements.
In this blog you can find some initial figures before performance optimization.

First attempt


For the initial measurement I created two services. Exactly same services just with one difference.
One configured using policies, one without any policy attached to it.
The wsdl file for the first one follows:
<?xml version="1.0"?>
<definitions xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://me.org/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.xmlsoap.org/wsdl/"
targetNamespace="http://me.org/" name="SillyServiceService">
<wsp:UsingPolicy/>
<wsp:Policy
xmlns:ns1="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"
ns1:Id="SillyServicePortBindingPolicy">
<wsp:ExactlyOne>
<wsp:All>
<ns7:OptimizedMimeSerialization
xmlns:ns7="http://schemas.xmlsoap.org/ws/2004/09/policy/optimizedmimeserialization"/>
<ns8:RMAssertion
xmlns:ns8="http://schemas.xmlsoap.org/ws/2005/02/rm/policy">
<ns8:InactivityTimeout Milliseconds="600000"/>
</ns8:RMAssertion>
<ns9:SupportingTokens
xmlns:ns9="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
<wsp:Policy>
<wsp:ExactlyOne>
<wsp:All>
<ns9:X509Token
ns9:IncludeToken="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy/IncludeToken/AlwaysToRecipient">
<wsp:Policy>
<wsp:ExactlyOne>
<wsp:All>
<ns9:RequireThumbprintReference/>
<ns9:WssX509V3Token11/>
</wsp:All>
</wsp:ExactlyOne>
</wsp:Policy>
</ns9:X509Token>
</wsp:All>
</wsp:ExactlyOne>
</wsp:Policy>
</ns9:SupportingTokens>
<ns10:SymmetricBinding xmlns:ns10="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
<wsp:Policy>
<wsp:ExactlyOne>
<wsp:All>
<ns10:AlgorithmSuite>
<wsp:Policy>
<wsp:ExactlyOne>
<wsp:All>
<ns10:Basic128/>
</wsp:All>
</wsp:ExactlyOne>
</wsp:Policy>
</ns10:AlgorithmSuite>
<ns10:IncludeTimestamp/>
<ns10:Layout>
<wsp:Policy>
<wsp:ExactlyOne>
<wsp:All>
<ns10:Strict/>
</wsp:All>
</wsp:ExactlyOne>
</wsp:Policy>
</ns10:Layout>
<ns10:OnlySignEntireHeadersAndBody/>
<ns10:ProtectionToken>
<wsp:Policy>
<wsp:ExactlyOne>
<wsp:All>
<ns10:X509Token
ns10:IncludeToken="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy/IncludeToken/AlwaysToRecipient">
<wsp:Policy>
<wsp:ExactlyOne>
<wsp:All>
<ns10:RequireDerivedKeys/>
<ns10:WssX509V3Token11/>
</wsp:All>
</wsp:ExactlyOne>
</wsp:Policy>
</ns10:X509Token>
</wsp:All>
</wsp:ExactlyOne>
</wsp:Policy>
</ns10:ProtectionToken>
</wsp:All>
</wsp:ExactlyOne>
</wsp:Policy>
</ns10:SymmetricBinding>
<ns11:Trust10 xmlns:ns11="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
<wsp:Policy>
<wsp:ExactlyOne>
<wsp:All>
<ns11:MustSupportIssuedTokens/>
<ns11:RequireClientEntropy/>
<ns11:RequireServerEntropy/>
</wsp:All>
</wsp:ExactlyOne>
</wsp:Policy>
</ns11:Trust10>
<ns12:Wss10 xmlns:ns12="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
<wsp:Policy>
<wsp:ExactlyOne>
<wsp:All>
<ns12:MustSupportRefIssuerSerial/>
<ns12:MustSupportRefKeyIdentifier/>
</wsp:All>
</wsp:ExactlyOne>
</wsp:Policy>
</ns12:Wss10>
<ns13:Ordered xmlns:ns13="http://sun.com/2006/03/rm"/>
<ns14:UsingAddressing xmlns:ns14="http://www.w3.org/2006/05/addressing/wsdl"/>
</wsp:All>
</wsp:ExactlyOne>
</wsp:Policy>
<wsp:Policy
xmlns:ns15="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"
ns15:Id="SillyServicePortBinding_sayHelloInput_Policy">
<wsp:ExactlyOne>
<wsp:All>
<ns16:EncryptedElements xmlns:ns16="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy"/>
<ns17:EncryptedParts xmlns:ns17="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
<ns17:Body/>
</ns17:EncryptedParts>
<ns18:SignedElements xmlns:ns18="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy"/>
<ns19:SignedParts xmlns:ns19="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
<ns19:Body/>
</ns19:SignedParts>
</wsp:All>
</wsp:ExactlyOne>
</wsp:Policy>
<wsp:Policy
xmlns:ns20="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"
ns20:Id="SillyServicePortBinding_sayHelloOutput_Policy">
<wsp:ExactlyOne>
<wsp:All>
<ns21:EncryptedElements xmlns:ns21="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy"/>
<ns22:EncryptedParts xmlns:ns22="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
<ns22:Body/>
</ns22:EncryptedParts>
<ns23:SignedElements xmlns:ns23="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy"/>
<ns24:SignedParts xmlns:ns24="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
<ns24:Body/>
</ns24:SignedParts>
</wsp:All>
</wsp:ExactlyOne>
</wsp:Policy>
<types>
<xsd:schema>
<xsd:import namespace="http://me.org/" schemaLocation="http://localhost:8080/withPolicies/SillyServiceService?xsd=1"/>
</xsd:schema>
</types>
<message name="sayHello">
<wsp:PolicyReference URI="#SillyServicePortBindingPolicy"/>
<part name="parameters" element="tns:sayHello"/>
</message>
<message name="sayHelloResponse">
<part name="parameters" element="tns:sayHelloResponse"/>
</message>
<portType name="SillyService">
<operation name="sayHello">
<input message="tns:sayHello"/>
<output message="tns:sayHelloResponse"/>
</operation>
</portType>
<binding name="SillyPortBinding" type="tns:SillyService">
<wsp:PolicyReference URI="#SillyServicePortBindingPolicy"/>
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
<operation name="sayHello">
<wsp:PolicyReference URI="#SillyServicePortBinding_sayHelloInput_Policy"/>
<wsp:PolicyReference URI="#SillyServicePortBinding_sayHelloOutput_Policy"/>
<soap:operation soapAction=""/>
<input>
<wsp:PolicyReference URI="#SillyServicePortBinding_sayHelloInput_Policy"/>
<wsp:PolicyReference URI="#SillyServicePortBinding_sayHelloOutput_Policy"/>
<soap:body use="literal"/>
</input>
<output>
<wsp:PolicyReference URI="#SillyServicePortBinding_sayHelloInput_Policy"/>
<wsp:PolicyReference URI="#SillyServicePortBinding_sayHelloOutput_Policy"/>
<soap:body use="literal"/>
</output>
</operation>
</binding>
<service name="SillyServiceService">
<port name="SillyPort" binding="tns:SillyPortBinding">
<wsp:PolicyReference URI="#SillyServicePortBindingPolicy"/>
<soap:address location="http://localhost:8080/withPolicies/SillyServiceService"/>
</port>
</service>
</definitions>

And the same wsdl without policies (for the second service):
<?xml version="1.0"?>
<definitions
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:tns="http://me.org/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns="http://schemas.xmlsoap.org/wsdl/"
targetNamespace="http://me.org/" name="SillyServiceService">
<types>
<xsd:schema>
<xsd:import namespace="http://me.org/"
schemaLocation="http://localhost:8080/withoutPolicies/SillyServiceService?xsd=1"/>
</xsd:schema>
</types>
<message name="sayHello">
<part name="parameters" element="tns:sayHello"/>
</message>
<message name="sayHelloResponse">
<part name="parameters" element="tns:sayHelloResponse"/>
</message>
<portType name="SillyService">
<operation name="sayHello">
<input message="tns:sayHello"/>
<output message="tns:sayHelloResponse"/>
</operation>
</portType>
<binding name="SillyPortBinding" type="tns:SillyService">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
<operation name="sayHello">
<soap:operation soapAction=""/>
<input>
<soap:body use="literal"/>
</input>
<output>
<soap:body use="literal"/>
</output>
</operation>
</binding>
<service name="SillyServiceService">
<port name="SillyPort" binding="tns:SillyPortBinding">
<soap:address location="http://localhost:8080/withoutPolicies/SillyServiceService"/>
</port>
</service>
</definitions>

Please note, that size of the wsdl files differs a bit.
I was curious, what would happen if I measured time for obtaining
the wsdl docs via get method from published endpoints:

  • http://localhost:8080/withoutPolicies/SillyServiceService?wsdl
  • http://localhost:8080/withPolicies/SillyServiceService?wsdl

For more information I also bundled wsdl docs as a static content to deployed wars
and included them into measurements.

  • http://localhost:8080/withoutPolicies/SillyServiceService.wsdl
  • http://localhost:8080/withPolicies/SillyServiceService.wsdl

Figures I got from jmeter (http://jakarta.apache.org/jmeter/)
you can see bellow:

From the figures you can see, that policy processing indeed have an impact
on webservice communication performance as clients basically have to read wsdl docs
from server in order to get policies (i.e. config data) out of it.

The numbers show that when policies are used getting the wsdl is more than two times slower,
while in terms of throughput it is not that bad.

Ok, lets dive deeper with more suitable tool -- NetBeans Profiler (http://www.netbeans.org/products/profiler/) to find out where possible improvements might be done.

Figures from NetBeans Profiler


What's bellow is just several screenshots and a few comments. I will come back to them
in another blog soon.

From Java Case (JSR-109 Compliant)

Quite good. Policy code needed about 17 % of time when wsdl was generated:

Which methods took the time?:

Hotspots:

From WSDL Case

Here it is worse. Policy processing took about 45 % of wsdl parser time:

Let's see which methods did it:

And what about hotspots?:

Be the first to comment

Comments ( 0 )
Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.Captcha