WARNING: This server provides a static reference view of the NetKernel documentation. Links to dynamic content do not work. For the best experience we recommend you install NetKernel and view the documentation in the live system .

Endpoint
Name:Throttle
Description:Throttles requests to allow a configured number to be passed concurrently
Id:layer1.Concurrency.Throttle
Category:transparent overlay

Throttle is a transparent overlay. You must instantiate an instance of the overlay from its prototype, this will create a new instance within your application space.

Parameters

The layer1.Concurrency.Throttle prototype has the following initialisation parameters:

NameRulesTypingDefaultDescription
configOptionalIdentifier or XML(none)
Configuration for the throttle
spaceMandatorySpace(none)
A nested space definition which the overlay will delegate all requests in to.

Here is an auto-generated example of how to instantiate an instance of Throttle:

<overlay>
  <prototype>layer1.Concurrency.Throttle</prototype>
  <space>
    <!--wrapped space...-->
  </space>
</overlay>
Import Requirements

To use Throttle transparent overlay you must import the module urn:org:netkernel:ext:layer1:

<import>
  <uri>urn:org:netkernel:ext:layer1</uri>
</import>

Requests pass through the throttle to the wrapped space as long as there are no more than concurrency requests active simultaneously. If a request arrives and there are already concurrency active requests in the wrapped space then the request will be placed in the request queue. When an active request completes then the next waiting request in the queue is allowed to progress to the wrapped space. If a request arrives at the throttle and there are already queue requests in the request queue then the request is reject and will be given a NKFException with "Throttle Overload".

Configuration

Configuration may be supplied with the config parameter of the form...

<config>
  <concurrency>8</concurrency>
  <queue>250</queue>
</config>

  • concurrency should be be a positive integer that specifies how many simultaneous requests can be active in the wrapper space. Defaults to 8 if not specified.
  • queue should be be greater than or equal to zero and specifies the size of the queue used to hold requests that exceed the concurrency limit. Defaults to 250 if not specified.

Example

An application uses a commercial RDBMS server with strict licensing requirements to not exceed two active requests. To ensure license compliance a throttle overlay is place around the database module.

<overlay>
  <prototype>layer1.Concurrency.Throttle</prototype>
  <config>
    <concurrency>2</concurrency>
    <queue>500</queue>
  </config>
  <space>
    <import>
      <uri>urn:org:netkernel:mod:db</uri>
    </import>
  </space>
</overlay>