Skip to main content

Multi White-listing And Advance Throttling with WSO2 API Manager


After spending few sleepless nights found a workaround to do multi IP whitelisting and throttling on API manager as following.
Multi IP whitelisting and throttling is not supported by wso2 API manager pack. There are two options we have tried,

1. IP based Throttling

Go to API manager admin portal https://13.58.109.76:9444/admin/api-policy-list
throttling policies > advanced throttling > add tier




Set Request Count as the default limit
Set 1 minute as unit time
Press on add condition group > press IP condition > press "on" on IP Condition Policy



Select specific IP as IP Condition type
Add an IP address to be whitelisted and throttled
Under Execution Policy
Select Request Count as Request Count
Set Request Count as you like
Set time to 1 minute

Press on add condition group again to add the second IP and repeat the same

Add this to the API by setting it on "Advanced Throttling Policies" on API manage page on publisher page.

Pros:
No backend code changes
Can be totally managed by the end user

Cons:
No API based throttling, only IP based throttling


2. API based Throttling

Follow all the steps as above
Go to API manager carbon console > Available Execution Plans
Search for the Advanced Throttling Policy name you created
There should be 3
carbon.super_resource_ATP-nuwan_default
carbon.super_resource_ATP-nuwan_condition_125
carbon.super_resource_ATP-nuwan_condition_124



Go to carbon.super_resource_ATP-nuwan_default
copy
(((cast(map:get(propertiesMap,'ip'),'Long')==221788567l)) OR ((cast(map:get(propertiesMap,'ip'),'Long')==221932876l)))


Now go to
carbon.super_resource_ATP-nuwan_condition_124
find (cast(map:get(propertiesMap,'ip'),'Long')==22178856799l)
and replace with above



Now go to carbon.super_resource_ATP-nuwan_condition_125
delete all the code after
FROM RequestStream


Pros:
can handle API throttling instead of IP only traffic

Cons:
Required dev involvement as its a siddhi level change
If a UI change is made for the policy need to redo these changes.













Comments

Popular posts from this blog

Oracle Database 12c installation on Ubuntu 16.04

This article describes how to install Oracle 12c 64bit database on Ubuntu 16.04 64bit. Download software  Download the Oracle software from OTN or MOS or get a downloaded zip file. OTN: Oracle Database 12c Release 1 (12.1.0.2) Software (64-bit). edelivery: Oracle Database 12c Release 1 (12.1.0.2) Software (64-bit)   Unpacking  You should have following two files downloaded now. linuxamd64_12102_database_1of2.zip linuxamd64_12102_database_2of2.zip Unzip and copy them to \tmp\databases NOTE: you might have to merge two unzipped folders to create a single folder. Create new groups and users Open a terminal and execute following commands. you might need root permission. groupadd -g 502 oinstall groupadd -g 503 dba groupadd -g 504 oper groupadd -g 505 asmadmin Now create the oracle user useradd -u 502 -g oinstall -G dba,asmadmin,oper -s /bin/bash -m oracle You will prompt to set to password. set a momorable password and write it down. ...

DBCA : No Protocol specified

when trying to execute dbca from linux terminal got this error message. now execute the command xhost, you probably receiving No protocol specified xhost:  unable to open display ":0" issue is your user is not allowed to access the x server. You can use xhost to limit access for X server for security reasons. probably you are logged in as oracle user. switch back to default user and execute xhost again. you should see something like SI:localuser:nuwan solution is adding the oracle to access control list xhost +SI:localuser:oracle now go back to oracle user and try dbca it should be working

Java Multithreading 2021

Thread Thread Is a subprocess that follows a separate execution path, different stack frame and executes independently but they share the same process resources.  Multithreading is the process of executing one or more threads simultaneously that helps in executing multiple tasks at the same time. Advantages less memory fast efficient Supports multitasking Exception in one thread does not affect the other    Thread lifecycle New Runnable Running Non-Runnable Terminated   Ways to create a thread? Extending Thread class Implementing Runnable class   Thread.start() vs Thread.run() Class java.lang.Thread .start() Creates a new thread and the run() method is executed on the newly created thread. Can’t be invoked more than one time otherwise throws java.lang.IllegalStateException.  Interface java.lang.Runnable.run(), No new thread is created and the run() method is executed on the calling thread itself. Multiple invocation is possible   Constructors of a th...