Wednesday, August 31, 2011

How to configure throttling in Cloud Environment using WSO2 Stratos – Users Guide


Here in this post i hope to discuss how to set up wso2 Stratos with throttling. In this post i will mainly focus on how to setup and fine tuning parameters for throttling and usage metering. If you need more information on usage metering and throttling see my previous post from here. First you need to understand few terms.If you need to understand more on throttling on Cloud environment please refer the this post on Amila Maharachchi’s Blog 
Throttling Manager – Manage, Evaluate what users can do and cannot do based on their subscription plans and their current usage.
Throttling Agent – This component detects user actions and allow them to do it or block it based on the Validation information generated by throttling manager
Usage Plan- There 4 types of usage plans available at WSO2 services. According to usage plan users will allow different volume of resources and service usage.(Demo/SMB/Professional/Enterprise). You will see more information on usage plans available at WSO2 StratosLive from here.
So we have to configure few things in order to work properly
01. How often throttling manager executes. Throttling manager periodically evaluates the tenants usage of resources(Service/webApp bandwidth, Registry usage, User count) and check it with their maximum allowed limit. After that process it store this validation data on registry. Here we can configure when start this evaluation process and how often we do this. To configure this we have to change configuration file( throttling-config.xml ). Before that you have to set up WSO2 Stratos properly(Manager/ IS/ any other services). Then go to inside of manager/repository/conf folder. There you will see throttling-config.xml file and that file has following entries.
<parameters>
<parameter name="interval">60</parameter>
<!--minutes = If This set to negative(-) value then throttling manager excecution will disable-->
<parameter name="delay">15</parameter>
</parameters>
interval parameter is there to specify the time frequency(in minutes) of executing throttling manager.According to this configuration it says execute rules after 60 minutes. With this configuration Manager will detect any excess usage of resources within one hour. after each 60 minutes It will call Data services and get current usage of each and every tenant and updating their actions(What they are allow to do or what they are not allowed)
delay parameter is there to define when to start first rule execution.According to this configuration server will run first throttling rule execution after 15 minutes time of server started.
15 minutes and 60 minutes are recommended values. But if you need much more accuracy you can reduce that interval value(But its advisable use some value more than 3 minutes otherwise it will causes to performance drop). And also remember reducing this time always causes to higher CPU Usage. If you don't need to run throttling manager you can disable it by setting negative value for  interval parameter. If you plan to run manager instance without throttling you can use this configuration.
02. How other Services allow to use Throttling manager. In order to  use throttling manager by services we have to modify configuration in each and every services that we use(Appserver/ IS/ BAM/ DSS etc..). Those services need to access throttling manager at WSO2 Stratos Manager. In that case we have to modify throttling-agent-config.xml file. That file has following content.
<throttlingAgentConfig xmlns="http://wso2.com/carbon/multitenancy/throttling/agent/config">
<parameters>
<parametername="managerServiceUrl">https://cloud-test.wso2.com/services/</parameter>
<parameter name="userName">admin</parameter>
<parameter name="password">admin</parameter>
</parameters>
</throttlingAgentConfig>
managerServiceUrl – is the URL of manager running on. Manager services URL. you will see this URL when manager starts up at terminal. by default this will set to local host.
userName – Here we have to specify Stratos Manager server super admin user name (By default it will be admin)
password  Here we have to specify Stratos Manager server super admin password (By default this will be admin)
This configuration is used by other services except manager to run the throttling rules at manager. As an example when we try to add new user identity server will call manager throttling manager to report new user adding. Otherwise within one hour of throttling rule execution time tenant user may add any number of users. To avoid such misuses we use this technique.
03. How to write throttling rules. For each usage plans we have to specify the upper limit of resource and service usage. And then if any user try to go beyond that limit throttling agent will stop that action immediately. As example if Demo account is allow to add 1 users we have to specify it in throttling rules. You will see throttling-rules.drl file inside manager/repository/conf. At first time manager takes rules from that file and store it in registry. Only super admin user for stratos manager allow to change throttling rules. If you logged in as super Admin you will see throttling menu. by clicking it you will see throttling rules editor window where you can write rules. There is other blog post on how to write throttling rules if you are interested please refer it .


No comments:

Post a Comment