title: Mule CPU maxing out with a very small load
body: <p>System under test: Mule ESB 3.3.1
  OS: CentOS 5.1 64 bit
  Quad-core 3 GHz
  32 GB RAM</p>
  
  <p>The Mule ESB is simply intercepting SOAP requests; validating the SOAP requests for a valid token and simply forwarding the request to a pre-determined web server hosting the web service.</p>
  
  <p>When we run performance tests using SOAP UI, the CPU maxes to 100% very very quickly at 10 requests per second.</p>
  
  
  
  <pre><code>&lt;spring:beans&gt;
       &lt;spring:bean class="ca.mpac.soa.BAMNotificationListener" id="BAMNotificationListener"/&gt;
       &lt;context:component-scan base-package="ca.mpac.soa"/&gt;
       &lt;util:properties id="appProps" location="classpath:bedrock.properties"/&gt;
  &lt;/spring:beans&gt;
  &lt;notifications&gt;
      &lt;notification event="COMPONENT-MESSAGE"/&gt; &lt;notification-listener ref="BAMNotificationListener"/&gt;
  &lt;/notifications&gt;
  
  &lt;context:property-placeholder location="bedrock.properties"/&gt;
  &lt;object-to-string-transformer name="SecurityTokenResponseToString" doc:name="Object to String"/&gt;
  &lt;custom-transformer name="WSDLTransformer" class="ca.mpac.soa.WSDLTransformer" doc:name="Java"/&gt;
  
  &lt;flow name="bedrock" doc:name="bedrock"&gt;
              &lt;http:inbound-endpoint exchange-pattern="request-response" host="${proxy.host}" port="${proxy.port}" doc:name="proxy"&gt;
                      &lt;not-filter&gt;
                              &lt;wildcard-filter pattern="/favicon.ico" caseSensitive="true"/&gt;
                      &lt;/not-filter&gt;
              &lt;/http:inbound-endpoint&gt;
      &lt;component class="ca.mpac.soa.HttpAccessLog" doc:name="HttpAccessLog"/&gt;
      &lt;!-- &lt;logger message="#[header:INBOUND:http.version] #[header:INBOUND:http.method] #[header:INBOUND:Host]#[header:INBOUND:http.request.path]?#[header:INBOUND:http.query.string] #[header:INBOUND:MULE_REMOTE_CLIENT_ADDRESS] #[header:INBOUND:User-Agent]" level="INFO" doc:name="Header Information" category="mule.http.accesslog"/&gt; --&gt;
      &lt;!-- logger message="Incoming request: #[payload]" level="INFO" doc:name="Incoming request"/&gt; --&gt;
      &lt;choice doc:name="Choice"&gt;
          &lt;when evaluator="groovy" expression="message.getInboundProperty('http.request.path')==~'^/rest/.*'"&gt;
              &lt;processor-chain&gt;
                  &lt;flow-ref name="REST" doc:name="REST Flow"/&gt;
              &lt;/processor-chain&gt;
          &lt;/when&gt;
          &lt;when evaluator="groovy" expression="message.getInboundProperty('http.request.path')==~'^/soap/.*'"&gt;
              &lt;processor-chain&gt;
                  &lt;flow-ref name="SOAP" doc:name="SOAP Flow"/&gt;
              &lt;/processor-chain&gt;
          &lt;/when&gt;
          &lt;otherwise&gt;
              &lt;processor-chain&gt;
                  &lt;flow-ref name="404NotFound" doc:name="404 Not Found"/&gt;
              &lt;/processor-chain&gt;
          &lt;/otherwise&gt;
      &lt;/choice&gt;
  &lt;/flow&gt;
  &lt;sub-flow name="REST" doc:name="REST"&gt;
      &lt;!-- logger message="Launching REST Flow: #[payload]" level="INFO" doc:name="Launching REST Flow"/&gt; --&gt;
      &lt;choice doc:name="Choice"&gt;
          &lt;when evaluator="groovy" expression="message.getInboundProperty('http.request.path')==~'^/rest/security/gettoken$'"&gt;
              &lt;processor-chain&gt;
                  &lt;choice doc:name="Choice"&gt;
                      &lt;when evaluator="header" expression="INBOUND:http.method=POST"&gt;
                          &lt;processor-chain&gt;
                              &lt;mulexml:xml-to-object-transformer returnClass="ca.mpac.soa.ClientAuthenticationRequest" doc:name="XML to Object"&gt;
                                  &lt;mulexml:alias name="credential" class="ca.mpac.soa.ClientAuthenticationRequest"/&gt;
                              &lt;/mulexml:xml-to-object-transformer&gt;
                              &lt;!-- logger message="Accessing to ${openam.host}:${openam.port}/openam/identity/authenticate?username=#[payload.username]&amp;amp;password=#[payload.password]&amp;amp;uri=realm=${openam.realm}" level="INFO" doc:name="Accessing to URL"/&gt; --&gt;
                              &lt;http:outbound-endpoint exchange-pattern="request-response" host="${openam.host}" port="${openam.port}" path="openam/identity/authenticate?username=#[payload.username]&amp;amp;password=#[payload.password]&amp;amp;uri=realm=${openam.realm}" method="GET" responseTransformer-refs="SecurityTokenResponseToString" doc:name="OpenAM Get Token"/&gt;
                              &lt;choice doc:name="Choice"&gt;
                                  &lt;when evaluator="header" expression="INBOUND:http.status=200"&gt;
                                      &lt;processor-chain&gt;
                                          &lt;logger message="Getting Token: #[payload]" level="INFO" doc:name="Getting Token"/&gt;
                                      &lt;/processor-chain&gt;
                                  &lt;/when&gt;
                                                          &lt;otherwise&gt;
                                                              &lt;processor-chain&gt;
                                                                              &lt;!-- &lt;logger message="401 Access Denied: Invalid Account Information" level="INFO" doc:name="401 Access Denied"/&gt; --&gt;
                                                                                  &lt;set-payload value="401 Access Denied: Invalid Account Information" doc:name="401 Access Denied" /&gt;
                                                                              &lt;http:response-builder status="401" doc:name="HTTP 401" contentType="text/plain"/&gt;
                                                                  &lt;/processor-chain&gt;
                                                          &lt;/otherwise&gt;
                              &lt;/choice&gt;
                          &lt;/processor-chain&gt;
                      &lt;/when&gt;
                                  &lt;otherwise&gt;
                                      &lt;processor-chain&gt;
                                          &lt;flow-ref name="405MethodNotAllowed" doc:name="405 Method Not Allowed"/&gt;
                                      &lt;/processor-chain&gt;
                                  &lt;/otherwise&gt;
                  &lt;/choice&gt;
              &lt;/processor-chain&gt;
          &lt;/when&gt;
          &lt;otherwise&gt;
              &lt;processor-chain&gt;
                  &lt;flow-ref name="404NotFound" doc:name="404 Not Found"/&gt;
              &lt;/processor-chain&gt;
          &lt;/otherwise&gt;
      &lt;/choice&gt;
  &lt;/sub-flow&gt;
  
  &lt;sub-flow name="SOAP" doc:name="SOAP"&gt;
      &lt;!-- &lt;logger message="Launching SOAP Flow: #[payload]" level="INFO" doc:name="Launching SOAP Flow"/&gt; --&gt;
              &lt;choice doc:name="Choice"&gt;
          &lt;when evaluator="groovy" expression="message.getInboundProperty('http.request')==~'^/soap/BuildingPermitService/v1/BuildingPermit\\?.*'"&gt;
              &lt;processor-chain&gt;
                  &lt;choice doc:name="Choice"&gt;
                      &lt;when evaluator="header" expression="INBOUND:http.method=GET"&gt;
                          &lt;processor-chain&gt;
                              &lt;!-- &lt;logger message="Accessing to ${bpe.host}:${bpe.port}#[header:INBOUND:http.request.path]?#[header:INBOUND:http.query.string]" level="INFO" doc:name="Accessing to URL"/&gt; --&gt;
                              &lt;http:outbound-endpoint exchange-pattern="request-response" address="http://${bpe.host}:${bpe.port}#[header:INBOUND:http.request.path]?#[header:INBOUND:http.query.string]" method="GET" doc:name="SOAP Service" responseTransformer-refs="WSDLTransformer"/&gt;
                          &lt;/processor-chain&gt;
                      &lt;/when&gt;
                                  &lt;otherwise&gt;
                                      &lt;processor-chain&gt;
                                          &lt;flow-ref name="405MethodNotAllowed" doc:name="405 Method Not Allowed"/&gt;
                                          &lt;/processor-chain&gt;
                                  &lt;/otherwise&gt;
                  &lt;/choice&gt;
              &lt;/processor-chain&gt;
          &lt;/when&gt;
          &lt;when evaluator="groovy" expression="message.getInboundProperty('http.request')==~'^/soap/BuildingPermitService/v1/BuildingPermit$'"&gt;
              &lt;processor-chain&gt;
                  &lt;choice doc:name="Choice"&gt;
                      &lt;when evaluator="header" expression="INBOUND:http.method=POST"&gt;
                          &lt;processor-chain&gt;
                              &lt;component class="ca.mpac.soa.HttpRequestToAuthorization" doc:name="HttpRequest To Authorization"/&gt;
                                          &lt;choice doc:name="Choice"&gt;
                                              &lt;when evaluator="header" expression="INVOCATION:authResult=true"&gt;
                                                  &lt;processor-chain&gt;
                                                      &lt;!--
                                                      &lt;logger message="Accessing to ${bpe.host}:${bpe.port}#[header:INBOUND:http.request]" level="INFO" doc:name="Accessing to URL"/&gt;
                                          &lt;component class="ca.mpac.soa.SoapRequest" doc:name="SOAP Request"/&gt;
                                                      &lt;http:outbound-endpoint exchange-pattern="request-response" address="http://${bpe.host}:${bpe.port}#[header:INBOUND:http.request]" doc:name="SOAP Service" &gt;
                                                              &lt;cxf:proxy-client payload="envelope" /&gt;
                                                              &lt;logger message="#[payload]" level="INFO" doc:name="Logger"/&gt;
                                                      &lt;/http:outbound-endpoint&gt;
                                                      --&gt;
                                                      &lt;http:outbound-endpoint exchange-pattern="request-response" address="http://${bpe.host}:${bpe.port}/soap/BuildingPermitService/v1/BuildingPermit" doc:name="SOAP Service" &gt;
                                                              &lt;cxf:proxy-client payload="envelope" /&gt;
                                                              &lt;!-- &lt;logger message="#[payload]" level="INFO" doc:name="Logger"/&gt; --&gt;
                                                      &lt;/http:outbound-endpoint&gt;
                                                      &lt;!-- &lt;logger message="Discovered an Authorization Request" level="INFO" doc:name="Discovered an Authorization Request"/&gt; --&gt;
                                                  &lt;/processor-chain&gt;
                                              &lt;/when&gt;
                                              &lt;when evaluator="header" expression="INVOCATION:authResult=false"&gt;
                                                  &lt;processor-chain&gt;
                                                                              &lt;logger message="403 Authorization Failure" level="INFO" doc:name="403 Authorization Failure"/&gt;
                                                                              &lt;expression-component doc:name="403 AuthorizationFailure"&gt;&lt;![CDATA[
                                                                                               message.payload = '&lt;?xml version=\'1.0\' encoding=\'UTF-8\'?&gt;'
                                                                                                               + '&lt;soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"&gt;'
                                                                                                               + '&lt;soap:Body&gt;'
                                                                                                               + '&lt;soap:Fault&gt;'
                                                                                                               + '&lt;faultcode&gt;soap:Server&lt;/faultcode&gt;'
                                                                                                               + '&lt;faultstring&gt;A security fault has occured&lt;/faultstring&gt;'
                                                                                                               + '&lt;detail&gt;'
                                                                                                               + '&lt;ns2:securityFault xmlns:ns3="http://services.mpac.ca/soap/security/v1.0/schema" xmlns:ns2="http://services.mpac.ca/soap/common/faulttypes/v1.0/schema" xmlns="http://services.mpac.ca/soap/buildingpermit/v1.0/schema"&gt;'
                                                                                                               + '&lt;ns2:name&gt;AuthorizationFailure&lt;/ns2:name&gt;'
                                                                                                               + '&lt;ns2:status&gt;403&lt;/ns2:status&gt;'
                                                                                                               + '&lt;ns2:reason&gt;Client is unauthorized to use this service | please contact your MPAC representative&lt;/ns2:reason&gt;'
                                                                                                               + '&lt;/ns2:securityFault&gt;'
                                                                                                               + '&lt;/detail&gt;'
                                                                                                               + '&lt;/soap:Fault&gt;'
                                                                                                               + '&lt;/soap:Body&gt;'
                                                                                                               + '&lt;/soap:Envelope&gt;';
                                                                                      ]]&gt;&lt;/expression-component&gt;
                                                                              &lt;http:response-builder status="403" doc:name="HTTP 403" contentType="text/xml"/&gt;
                                                  &lt;/processor-chain&gt;
                                              &lt;/when&gt;
                                              &lt;when evaluator="header" expression="INVOCATION:authResult=401"&gt;
                                                  &lt;processor-chain&gt;
                                                                              &lt;logger message="401 Access Denied: Invalid Token" level="INFO" doc:name="401 Access Denied"/&gt;
                                                                                  &lt;expression-component doc:name="401 Access Denied: AuthenticationFailed"&gt;&lt;![CDATA[
                                                                                               message.payload = '&lt;?xml version=\'1.0\' encoding=\'UTF-8\'?&gt;'
                                                                                                               + '&lt;soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"&gt;'
                                                                                                               + '&lt;soap:Body&gt;'
                                                                                                               + '&lt;soap:Fault&gt;'
                                                                                                               + '&lt;faultcode&gt;soap:Server&lt;/faultcode&gt;'
                                                                                                               + '&lt;faultstring&gt;A security fault has occured&lt;/faultstring&gt;'
                                                                                                               + '&lt;detail&gt;'
                                                                                                               + '&lt;ns2:securityFault xmlns:ns3="http://services.mpac.ca/soap/security/v1.0/schema" xmlns:ns2="http://services.mpac.ca/soap/common/faulttypes/v1.0/schema" xmlns="http://services.mpac.ca/soap/buildingpermit/v1.0/schema"&gt;'
                                                                                                               + '&lt;ns2:name&gt;AuthenticationFailed&lt;/ns2:name&gt;'
                                                                                                               + '&lt;ns2:status&gt;401&lt;/ns2:status&gt;'
                                                                                                               + '&lt;ns2:reason&gt;Client authentication has failed | please contact your MPAC representative&lt;/ns2:reason&gt;'
                                                                                                               + '&lt;/ns2:securityFault&gt;'
                                                                                                               + '&lt;/detail&gt;'
                                                                                                               + '&lt;/soap:Fault&gt;'
                                                                                                               + '&lt;/soap:Body&gt;'
                                                                                                               + '&lt;/soap:Envelope&gt;';
                                                                                      ]]&gt;&lt;/expression-component&gt;
                                                                              &lt;http:response-builder status="401" doc:name="HTTP 401" contentType="text/xml"/&gt;
                                                  &lt;/processor-chain&gt;
                                              &lt;/when&gt;
                                                          &lt;otherwise&gt;
                                                              &lt;processor-chain&gt;
                                                                              &lt;component class="ca.mpac.soa.SoapActionErrorLog" doc:name="SoapActionErrorLog"/&gt;
                                                                              &lt;http:response-builder status="400" doc:name="HTTP 400" contentType="text/plain"/&gt;
                                                                  &lt;/processor-chain&gt;
                                                          &lt;/otherwise&gt;
                                          &lt;/choice&gt;
                          &lt;/processor-chain&gt;
                      &lt;/when&gt;
                                  &lt;otherwise&gt;
                                      &lt;processor-chain&gt;
                                          &lt;flow-ref name="405MethodNotAllowed" doc:name="405 Method Not Allowed"/&gt;
                                          &lt;/processor-chain&gt;
                                  &lt;/otherwise&gt;
                  &lt;/choice&gt;
              &lt;/processor-chain&gt;
          &lt;/when&gt;
          &lt;otherwise&gt;
              &lt;processor-chain&gt;
                  &lt;flow-ref name="404NotFound" doc:name="404 Not Found"/&gt;
                  &lt;/processor-chain&gt;
          &lt;/otherwise&gt;
      &lt;/choice&gt;
  &lt;/sub-flow&gt;
  
  &lt;sub-flow name="404NotFound" doc:name="404NotFound"&gt;
      &lt;logger message="404 Not Found: #[header:INBOUND:http.request]" level="INFO" doc:name="404 Not Found"/&gt;
      &lt;set-payload value="404 Not Found" doc:name="404 Not Found" /&gt;
      &lt;http:response-builder status="404" doc:name="HTTP 404" contentType="text/plain"/&gt;
  &lt;/sub-flow&gt;
  
  &lt;sub-flow name="405MethodNotAllowed" doc:name="405MethodNotAllowed"&gt;
      &lt;logger message="405 Method Not Allowed: #[header:INBOUND:http.method]" level="INFO" doc:name="405 Method Not Allowed"/&gt;
      &lt;set-payload value="405 Method Not Allowed" doc:name="405 Method Not Allowed" /&gt;
      &lt;http:response-builder status="405" doc:name="HTTP 405" contentType="text/plain"/&gt;
  &lt;/sub-flow&gt;
  </code></pre>
  
  <p></p>