All Kony Fabric Posts

API Throttling

Ajay Bhat - Dec 06, 2016 - Integration

In this post, Sriram Parisa discusses a key feature in the 7.2 release of MobileFabric: API throttling.

Throttle is an interim state, and is used to control the rate of requests that clients can make to an API. Kony has come up with an out of the box throttle mechanism to configure and control incoming requests to APIs (services). These limits can be configured from the console and help control the rate of the client’s consumption of the various APIs exposed through MobileFabric. This also acts a security measure.

API Throttling Options

Kony MobileFabric provides the following options to configure throttle limits

  • Total Rate Limit Throttling: This limits the number of calls per minute by configuring the Total Rate Limit value in MobileFabric Console. Use this option when you need to restrict only the number of request spawns per minute

  • Per IP Rate Limit Throttling: This limits the number of calls to the client per minute by configuring the per IP Rate Limit value in MobileFabric Console. Use this option when you have a need to restrict the number of requests spawned per IP.

How Does Kony API Throttling Work?

  1. The MobileFabric administrator configures throttling based on their needs as mentioned above.
  2. Client sends requests to the MobileFabric Server to invoke a API.
  3. Server first checks if the requests rate limit exceeded per IP rate limit configured in that Time Window? If yes, terminate.
  4. If no, server checks if the request rate limit exceeded the Total rate limit configured in that Time Window? If yes, terminate and if no, process the request further.

Time Window: The Time Window is the duration that MobileFabric manages internally to count the requests rate against the rate limit configured. As of now, this time windows is one minute.

API Throttling Block Diagram

Where to configure throttle limits?

  • Throttle limits can be configured in service definition tab of a service in MobileFabric console.
  • These values are service definition values and these can be overridden by runtime values configured at server admin console.

API Throttling settings on MobileFabric Console

Is there an option to override the throttle limits at runtime?

  • Log into Kony server admin console to view your list of services.
  • The last column helps in configuring the limits at runtime for a service (provided the throttle should have configured in MobileFabric console at service definition)
  • Click on that Icon to view the limits configured in MobileFabric Console and override the configurations using input texts available.

API Throttling runtime override

What happens when the rate limit is exceeded?

  • The request will not be processed and the response will be 429 HTTP status code (Too many requests) and error message is based on the throttling type. 

How do I configure API Throttling in a clustered environment?

  • Update the KONY_SERVER_NUMBER_OF_NODES property in server_configuration table available in Admin database. This indicates the number of nodes configured in the cluster. The default value is 1.

How does API throttling work in a multi-node environment?

  • The request limit is calculated as Request Limit/No. of nodes and “IP Limit” is at the environment level (Irrespective of no. of nodes)
  • Let say you have 2 nodes and “Request Limit” is set to 10 and “IP Limit” is set to 6.
  • Now, “Request Limit” is 5 per each node and “IP Limit” is 6 for all the Nodes.
  • Overall it will accept 6 requests from 2 nodes.

Is there a chance wherein, I have “Request Limit” as 3, throttle throws exception after 5 calls?

  1. This could happen when you have consumed 2 requests and you might have moved to the range of next minute (The range that accepts 3 more requests) by the time you are trying to hit 3rd request.
  2. In this case you will get the exception after 5 requests.

Questions?

Please post your questions to the Kony Community Forums.