Here in this post i hope to discuss how to set up wso2 Stratos with usage metering. In this post i will mainly focus on how to setup and fine tuning parameters for 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
Usage Agent – Component which measures resource usage(use listening technology) and store it (Publish it to other server to record it).This usage metering process use some advanced listening technologies to avoid slows down or blocks entire process.
As an example let say some web service(hosted by sanjeewa.com) is invoked by some client. so this invocation takes 100kb service bandwidth. So usage agent will store this entry this tenant(sanjeewa.com) got service bandwidth of 100kb at this time
In order to usage metering work properly we have to do few configurations in stratos services.Usage metering is based on simple concept that is listening. There few listeners to listen the actions performed by user and those listeners report what they heard to some other server(Business Activity Monitor). And those record will be store there in some ordered format.We will first identify those listeners.
01. Registry Listener – This listener will listen to each and every action related to registry(get, put, add, delete etc.. ) Then store them as bandwidth usage.
02. User Add Listener – This listener is there to listen user adding actions and keep updating user count of tenants
03. Service/Web App bandwidth listener – This listener is mainly listen to incoming and out going message sizes and store those data as bandwidth usages. For this listener usage agent use tomcat valve data statics.
See following Diagram for overview of usage metering process
Figure : Overview Of Usage Metering Process
Data publisher – Data publisher is available inside the usage agent.When usage agent starts Data publisher creates the connection to the end point of BAM. In order to do this we have to provide Server URL of BAM instance running on.Let see how we do this configuration.This usage metering process happens at each and every stratos service so usage agent is available in every service of stratos. You can see carbon.xml file in every service inside the repository/conf folder. In carbon.xml file you will see following entry
<BamServerURL>https://bam.cloud-test.wso2.com:9447/services/</BamServerURL>
You have to give correct BAM server URL with /services part. you will see this URL when bam server starts up.Then only usage agent will be able to publish data to BAM.
Then these metered usage data will be available for any decision making process. Users(Tenants) can view their usage and super administrator can can view all tenants usages. Throttling manager use those records to check whether users exceeded their allowed limits or not.
There are some other important parameters to configure for publisher.Those parameters are used configure to how we accumulate, how often we publish them to Bam kind of things. Since those configurations are developer level changes i will discuss it on separate post.
No comments:
Post a Comment