This site contains the documentation that is relevant to older WSO2 product versions and offerings.
For the latest WSO2 documentation, visit https://wso2.com/documentation/.

Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 18 Current »

The throttle mechanism is used to control access to the services at different levels. WSO2 ESB provides an effective and efficient way to apply the throttle mechanism to your Web services.

Levels of throttling

You can enable throttling at the following levels in WSO2 ESB:

  • Global level - If it is enabled globally, restrictions are applied globally (for every message coming into the server).
  • Service level - If it is enabled for a particular service, restrictions are applied to all the messages coming into that service.

Click on the relevant tab for instructions to add a throttling policy at the required level.

You can also specify the throttle policy within a proxy service configuration as a key by saving the policy in the registry or by saving it as a local entry. However, when you are not using the Management Console, you are required to manually create an entry in the <ESB_HOME/repository/deployment/server/servicemetafiles/<Service_Name>.xml file to enable throttling as shown in the example below.

<?xml version="1.0" encoding="UTF-8"?>
<serviceGroup name="ThrottleProxy" successfullyAdded="true">
   <service name="ThrottleProxy"
            exposedAllTransports="false"
            serviceDeployedTime="1431430083400"
            successfullyAdded="true">
      <operation name="mediate">
         <module name="addressing" version="4.2.0" type="engagedModules"/>
         <module name="POXSecurityModule" version="4.2.2" type="engagedModules"/>
         <module name="wso2statistics" version="4.2.2" type="engagedModules"/>
         <module name="ServerAdminModule" version="4.2.0" type="engagedModules"/>
         <module name="pagination" version="4.2.0" type="engagedModules"/>
      </operation>
      <bindings>
         <binding name="ThrottleProxySoap12Binding">
            <operation name="mediate"/>
            <operation name="GetMetadata"/>
         </binding>
         <binding name="ThrottleProxySoap11Binding">
            <operation name="mediate"/>
            <operation name="GetMetadata"/>
         </binding>
         <binding name="ThrottleProxyHttpBinding">
            <operation name="mediate"/>
            <operation name="GetMetadata"/>
         </binding>
      </bindings>
      <policies>
         <policy policyType="3">
            <policyUUID>WSO2ServiceThrottlingPolicy</policyUUID>
            <wsp:Policy xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy"
                        xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"
                        wsu:Id="WSO2ServiceThrottlingPolicy">
               <throttle:ServiceThrottleAssertion xmlns:throttle="http://www.wso2.org/products/wso2commons/throttle">
                  <wsp:Policy>
                     <throttle:ID throttle:type="IP">10.100.0.37</throttle:ID>
                     <wsp:Policy>
                        <throttle:Control>
                           <wsp:Policy>
                              <throttle:MaximumCount>5</throttle:MaximumCount>
                              <throttle:UnitTime>100000</throttle:UnitTime>
                              <throttle:ProhibitTimePeriod wsp:Optional="true">10000</throttle:ProhibitTimePeriod>
                           </wsp:Policy>
                        </throttle:Control>
                     </wsp:Policy>
                  </wsp:Policy>
                  <wsp:Policy>
                     <throttle:ID throttle:type="DOMAIN">localhost</throttle:ID>
                     <wsp:Policy>
                        <throttle:Control>
                           <wsp:Policy>
                              <throttle:MaximumCount>1</throttle:MaximumCount>
                              <throttle:UnitTime>10000</throttle:UnitTime>
                              <throttle:ProhibitTimePeriod wsp:Optional="true">10000</throttle:ProhibitTimePeriod>
                           </wsp:Policy>
                        </throttle:Control>
                     </wsp:Policy>
                  </wsp:Policy>
                  <wsp:Policy>
                     <throttle:ID throttle:type="IP">127.0.0.1</throttle:ID>
                     <wsp:Policy>
                        <throttle:Control>
                           <wsp:Policy>
                              <throttle:MaximumCount>1</throttle:MaximumCount>
                              <throttle:UnitTime>100000</throttle:UnitTime>
                              <throttle:ProhibitTimePeriod wsp:Optional="true">10000</throttle:ProhibitTimePeriod>
                           </wsp:Policy>
                        </throttle:Control>
                     </wsp:Policy>
                  </wsp:Policy>
               </throttle:ServiceThrottleAssertion>
            </wsp:Policy>
         </policy>
      </policies>
      <module name="addressing" version="4.2.0" type="engagedModules"/>
      <module name="POXSecurityModule" version="4.2.2" type="engagedModules"/>
      <module name="wso2statistics" version="4.2.2" type="engagedModules"/>
      <module name="ServerAdminModule" version="4.2.0" type="engagedModules"/>
      <module name="pagination" version="4.2.0" type="engagedModules"/>
      <parameter name="serviceType" type="1">proxy</parameter>
      <policyUUID>WSO2ServiceThrottlingPolicy</policyUUID>
      <parameter name="disableREST" type="1">true</parameter>
      <module name="wso2throttle" version="4.2.0" type="engagedModules"/>
      <association destinationPath="/repository/transports/https/listener"
                   type="exposedTransports"/>
      <association destinationPath="/repository/transports/http/listener"
                   type="exposedTransports"/>
   </service>
</serviceGroup>

The proxy service configuration in this example can be as follows.

<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
       name="ThrottleProxy"
       transports="https http"
       startOnLoad="true"
       trace="disable">
   <description/>
   <target>
      <endpoint>
         <address uri="http://localhost:9000/services/SimpleStockQuoteService"/>
      </endpoint>
      <inSequence>
         <log level="full"/>
      </inSequence>
   </target>
  <policy key="throttlePolicy1"/>
</proxy>

 The following is an example of a throttle policy configuration that can be saved in the registry or as a local entry.

You need to use the same string (e.g., throttlePolicy1) for the throttle policy key of both the proxy service configuration, and the local entry definition, which is saved in the registry.

<?xml version="1.0" encoding="UTF-8"?>
<localEntry xmlns="http://ws.apache.org/ns/synapse" key="throttlePolicy1">
   <wsp:Policy xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy"
               xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"
               wsu:Id="WSO2ServiceThrottlingPolicy">
      <throttle:ServiceThrottleAssertion xmlns:throttle="http://www.wso2.org/products/wso2commons/throttle">
         <wsp:Policy>
            <throttle:ID throttle:type="IP">10.100.0.37</throttle:ID>
            <wsp:Policy>
               <throttle:Control>
                  <wsp:Policy>
                     <throttle:MaximumCount>5</throttle:MaximumCount>
                     <throttle:UnitTime>100000</throttle:UnitTime>
                     <throttle:ProhibitTimePeriod wsp:Optional="true">10000</throttle:ProhibitTimePeriod>
                  </wsp:Policy>
               </throttle:Control>
            </wsp:Policy>
         </wsp:Policy>
         <wsp:Policy>
            <throttle:ID throttle:type="DOMAIN">localhost</throttle:ID>
            <wsp:Policy>
               <throttle:Control>
                  <wsp:Policy>
                     <throttle:MaximumCount>5</throttle:MaximumCount>
                     <throttle:UnitTime>100000</throttle:UnitTime>
                     <throttle:ProhibitTimePeriod wsp:Optional="true">10000</throttle:ProhibitTimePeriod>
                  </wsp:Policy>
               </throttle:Control>
            </wsp:Policy>
         </wsp:Policy>
         <wsp:Policy>
            <throttle:ID throttle:type="IP">127.0.0.1</throttle:ID>
            <wsp:Policy>
               <throttle:Control>
                  <wsp:Policy>
                     <throttle:MaximumCount>5</throttle:MaximumCount>
                     <throttle:UnitTime>100000</throttle:UnitTime>
                     <throttle:ProhibitTimePeriod wsp:Optional="true">10000</throttle:ProhibitTimePeriod>
                  </wsp:Policy>
               </throttle:Control>
            </wsp:Policy>
         </wsp:Policy>
      </throttle:ServiceThrottleAssertion>
   </wsp:Policy>
   <description/>
</localEntry>


  • No labels