Here in this post i will describe how to use usage metering and throttling in cloud environment. For this post i will use WSO2 stratos which is a complete Platform-as-a-Service for private and public clouds. Lets see how we do usage metering and throttling in stratos.
What is WSO2 Stratos ?
WSO2 Stratos is a complete SOA and developer platform offered as a self-service, multi-tenant, elastic runtime for private and public cloud infrastructures. What that means is that our complete SOA platform - now enhanced with Tomcat and Webapp support - is available as a "cloud native" runtime that you can either use on the Web (yes - you can try it out right now), on Amazon VPC, or on your own internal private cloud based on Ubuntu Enterprise Cloud, Eucalyptus and (coming soon) vmWare vSphere. It is a complete Platform-as-a-Service for private and public clouds.
Download stratos source and more documents available at http://wso2.org/library/stratos
Post on how to build stratos 1.5.1 source available at
http://sanjeewamalalgoda.blogspot.com/2011/08/how-to-build-wso2-stratos-151-from.html
Sign up for a free account at stratos private cloud https://stratoslive.wso2.com
What is Tenant ?
In stratos we used term tenant. What is tenant? it’s like an organization (sanjeewa.com) and it may few users (like departments within organization). There is administrator for each tenant and others are users. Administrator can allow users to use services and he is the person who governs the entire system for tenant. See following diagram for understanding tenant.
Figure: Tenant and its users
Why we need Usage and Throttling ?
WSO2 stratos throttling component is the only one tomcat server based throttling module. And WSO2 Stratos 1.5.1 provides many new features like metering throttling and billing. So with WSO2 Stratos you will be able to measure, throttle and bill the server usage. Its really important to have reliable billing/ throttling model for cooperate service providers. Stratos 1.5.1 provides complete solution for web services with pricing model. So we will look at this usage and throttling model in detail. So this process has 2 main actions.
1. Before user perform some action we will check whether he is allow to do it or not(Ex adding new service/ service invocation).
2. After performing some action we keep it record (sanjeewa.com tenant used 100kb service Bandwidrh)
See following diagram for overview of usage and throttling.
Figure : Usage And Throttling Overview
Usage AgentUsage agent is responsible for measure parameters and publishes them into Business Activity monitor server(Where we store data and monitor). for each and every tenants agent measure some important parameters related to their usage of bandwidth and resources(Service/webApp bandwidth, Registry usage, User count). 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 try to invoke by some client so this invocation takes 100kb service bandwidth. So we will store this entry this tenant(sanjeewa.com) got service bandwidth of 100kb at this time
Usage Summery generator
Summery generator component responsible for summarize captured data. And after collecting raw data we do sorting and summarization periodically and store those records in database. Those records are available per hourly, monthly, daily, quarterly and annually.
As example after hour we will put above 100kb entry to hourly table. Then at the end of the day it will go to daily table with corresponding day of month.
Throttling Manager
Throttling is used to avoid excess usage of resources and bandwidth. Throttling manager periodically check the usage records(The data captured by above mentioned usage agent) available and evaluate throttling rules and define set of actions for each and every tenant. These actions are contain what tenants can do what cannot do what are the error messages that we have to show them. Those rules are written in drools. Drools is a business rule management system (BRMS) with a forward chaining inference based rules engine, more correctly known as a production rule system, using an enhanced implementation of the Rete algorithm. Using a rules engine can lower an application's maintenance and extensibility costs by reducing the complexity of components that implement complex business logic. So inside WSO2 stratos throttling component is use drools for throttling configurations and provide user interface to change rules in easier way. After evaluating Throttling rules for each tenant we will store the validation information(What tenant allow to do and what should block) in registry with tenant ID
Example :Throttling manager check the monthly data available in monthly service bandwidth table and check the Drool correspond to that tenant(Drool specify the service bandwidth allow to this user and actions when limit exceeding). If that user didn’t exceed limit it will put entry to registry saying sanjeewa.com is allow to service invocation else it will put entry saying not allowed.
Throttling Agent
Throttling agent is acting as a supervising agent who check the actions taken by users. Basically this will check registry entry for given tenant (Put by throttling manager). To achieve higher performance throttling agent use in memory implementation. It will take copy of registry entries and keep it cached. So reading validation information from cache is much faster than reading registry.
As an example When some tenant/users try to invoke web service this agent check the corresponding registry entry for user weather he is allow to do this or not. If he can do agent will allow to do it otherwise it will prompt message to user saying the issue.
No comments:
Post a Comment