Sunteți pe pagina 1din 14

Improving Operational Agility and Efficiency involved in Load Balancing and Scaling using Windows Azure

Cloud & Mobile COE, Marlabs


Auto scaling is a way to automatically scale up or down the number of compute resources based on user-defined policies, Key Performance Indicators (KPI), health status checks, and schedules. If your application needs more computing power, you can launch additional compute instances on-demand and use them for as long as you want, and then terminate them when they are no longer needed

Improving Operational Agility and Efficiency involved in Load Balancing and Scaling using Windows Azure

Cloud & Mobile COE, Marlabs Version 1.0


http://www.marlabs.com

Improving Operational Agility and Efficiency involved in Load Balancing and Scaling using Windows Azure

Table of Contents
Introduction .................................................................................................................................................. 3 The Business Need for Auto Scaling.............................................................................................................. 3 Example Scenarios for Auto Scaling .......................................................................................................... 3 Major benefits of using Auto Scaling ........................................................................................................ 4 Operational Agility ................................................................................................................................ 4 Elastic Scalability ................................................................................................................................... 4 Guard the Budget .................................................................................................................................. 4 Cost Savings .......................................................................................................................................... 4 Notifications .......................................................................................................................................... 5 Windows Azure Autoscaling Application Block (WASABi) ............................................................................ 5 Major functionalities of Windows Azure .................................................................................................. 5 Instance Scaling..................................................................................................................................... 5 Throttling .............................................................................................................................................. 5 Notifying................................................................................................................................................ 5 Custom action ....................................................................................................................................... 5 Adding Autoscaling Application Block to Host Application........................................................................... 6 Hosting the Autoscaling Application Block in a Windows Azure Worker Role ............................................. 7 Instantiate and Run the Scaler .................................................................................................................. 7 Import Namespaces .............................................................................................................................. 7 Resolve an instance of Autoscaler class................................................................................................ 7 Edit Autoscaling Application Block Configuration..................................................................................... 8 Author Rule Configuration File ............................................................................................................... 11 Author Service Configuration File ........................................................................................................... 12 Quick Steps to Add and Use Autoscaling Application Block ....................................................................... 12 Windows Azure Compute Resources to Host Autoscaling Application Block............................................. 13

Improving Operational Agility and Efficiency involved in Load Balancing and Scaling using Windows Azure

Introduction
Cloud computing is the set of technologies and infrastructure capabilities being offered in a service based consumption model. Windows Azure is Microsofts Cloud computing offering to build and deploy applications on a Pay-per-use basis. Cloud computing with Microsoft Windows Azure platform lets the customers to focus on delivering services to their customers rather than managing technology infrastructure. One of the key benefits of using Cloud computing is the ability for on-demand scalability of the applications deployed in Cloud. Dynamic provision for load balancing and scaling can dramatically reduce operational overheads, time, and costs and can improve efficiency of the applications deployed over the Cloud. Microsofts patterns & practices team is providing an Auto Scaling solution for Windows Azure that will provides dynamic provision for auto scaling based on the rules defined by the users for the applications scalability needs and organizational strategy.

What is Auto Scaling?


Auto scaling is a way to automatically scale up or down the number of compute resources based on user-defined policies, Key Performance Indicators (KPI), health status checks, and schedules. If your application needs more computing power, you can launch additional compute instances on-demand and use them for as long as you want, and then terminate them when they are no longer needed.

The Business Need for Auto Scaling


Auto Scaling is an extremely important service when we are building cloud based applications. Since cloud computing is a pay-per-use utility service and provides on-demand scalability, dynamic provisioning for scale up and scale down of cloud resources are very important functionality for cloud based applications. Dynamic provisioning for auto scaling can provide better scalability and can also guard organizational budget for cloud deployments. Auto Scaling balances between costs and performance to business organizations when they are moving to cloud.

Example Scenarios for Auto Scaling


The following are the few example scenarios where Auto Scaling service can provide business values.

Improving Operational Agility and Efficiency involved in Load Balancing and Scaling using Windows Azure

You can instruct the Auto Scaling service to launch an additional compute instances whenever CPU usage is high for a pre-defined time. You can instruct the Auto Scaling service to terminate few compute instances whenever CPU usage is low for a pre-defined time. You can instruct the Auto Scaling service to terminate few compute instances over the weekend when traffic is expected to be low. You can instruct the Auto Scaling service to launch an additional compute instances over the evening time of week days when traffic is expected to be high. You can instruct the Auto Scaling service to launch an additional compute instances when messages on your applications queue service is very high. You can configure the Auto Scaling service for receiving email notifications whenever compute usage is very high or low.

The above conditions are just few example scenarios, but the Auto Scaling can provide business values to many situations based on the behavior of your applications and the organizational strategy. This can reduce lot of manual tasks involved in load balancing and scaling and can staying on budget. Auto Scaling will help the enterprises to save both time and money and can improve business agility. Auto Scaling is a must have service when organizations are moving their applications onto Cloud.

Major benefits of using Auto Scaling


The following are the key features and benefits of using an Auto Scaling service

Operational Agility
Auto Scaling service can reduces lot of manual tasks involved in load balancing and scaling which will enables the overall operational agility and better productivity.

Elastic Scalability
Auto Scaling service can dynamically add compute resources when application usage rises and remove it when usage drops.

Guard the Budget


Organizations can guard their financial budget for C loud based applications. They can define and control the number of computing instances using well defined conditions.

Cost Savings
Auto Scaling service can save usage costs of compute resources by terminating underused instances automatically and launching new instances when applications need more compute resources.

Improving Operational Agility and Efficiency involved in Load Balancing and Scaling using Windows Azure Notifications

The Auto Scaling service can also use for receiving notifications and alerts about the load situations and health statuses.

Windows Azure Autoscaling Application Block (WASABi)


The Windows Azure Autoscaling Application Block (WASABi) lets the cloud developers to add and manage automatic scaling behavior to Windows Azure applications that provides all the functionality needed to define and monitor autoscaling behavior in a Windows Azure application or a group of Windows Azure applications. The Windows Azure Autoscaling Application Block is a part of the Microsoft Enterprise Library provided by the Microsoft patterns & practices team. The Windows Azure Autoscaling Application Block can automatically scale Windows Azure applications based on the rules defined in configuration files specifically for the hosted Windows Azure application. The block will read the rules and monitor Windows Azure applications and scale-up or scale-down the applications based on the rules. The Autoscaling Application Block can be hosted on a Windows Azure worker role application or in an on-premises application. The Enterprise Library provides a GUI based configuration tool that can be used for edit configuration settings for the Autoscaling Application Block.

Major functionalities of Windows Azure


The following are the key functionalities of Autoscaling Application Block

Instance Scaling
The Autoscaling Application Block varies the number of role instances in order to accommodate variations in the load on the application. Instance scaling actions can span multiple host services/subscriptions.

Throttling
Instead of spinning off new instances, the block limits or disables certain expensive operations in your application when the load is above certain thresholds.

Notifying
Instead of performing instance scaling or throttling, the user may elect to simply receive notifications about the load situations with no automatic scaling taking place.

Custom action
We can build extensions using the extensibility features provided by Autoscaling Application Block.

Improving Operational Agility and Efficiency involved in Load Balancing and Scaling using Windows Azure

Adding Autoscaling Application Block to Host Application


The Autoscaling Application Block is available as a NuGet package .The following steps will add the Autoscaling Application Block onto your host application. 1. Add a reference to the Autoscaling Application Block assembly. In Microsoft Visual Studio, right-click your project node in Solution Explorer, and then click Manage NuGet Packages. 2. Click the Online button, and then in the Search Online box, type WASABi. 3. Click the Install button for the Enterprise Library 5.0 Windows Azure Autoscaling Application Block Beta package. 4. Read and accept the license terms for the packages listed.

The NuGet package will add the all necessary assemblies and references to your project that you need to use the Autoscaling Application Block. The NuGet package will also add the XML schema files for the autoscaling rule definitions and autoscaling service information.

Improving Operational Agility and Efficiency involved in Load Balancing and Scaling using Windows Azure

Hosting the Autoscaling Application Block in a Windows Azure Worker Role


Autoscaling Application Block needs a host to run. The Autoscaling Application Block can be hosted on a Windows Azure worker role application or in an on-premises application. The following step by step instructions will help you to host the Autoscaling Application Block onto Windows Azure Worker Role.

Instantiate and Run the Scaler


The following steps will instantiate and run the Autoscaling Application Block in a Windows Azure Worker Role.

Import Namespaces
Import the following namespaces to the Worker Role class
using Microsoft.Practices.EnterpriseLibrary.Common.Configuration; using Microsoft.Practices.EnterpriseLibrary.WindowsAzure.Autoscaling;

Resolve an instance of Autoscaler class


The Autoscaler class is the main entry point for the Autoscaling Application Block from your host application. The following code block instantiates the Autoscaler class and call its start method for monitoring the Autoscaling behavior.
Autoscaler scaler = EnterpriseLibraryContainer.Current.GetInstance<Autoscaler>(); scaler.Start();

The following code block shows implementation of Worker Role class


public class WorkerRole : RoleEntryPoint { private Autoscaler autoscaler; public override void Run() { autoscaler = EnterpriseLibraryContainer.Current.GetInstance<Autoscaler>(); autoscaler.Start(); while (true) { Thread.Sleep(10000); Trace.WriteLine("Working", "Information"); } }

Improving Operational Agility and Efficiency involved in Load Balancing and Scaling using Windows Azure
public override bool OnStart() { // *** AzureAutoScale-Start *** //Set Max number of concurrent connections ServicePointManager.DefaultConnectionLimit = 12;

DiagnosticMonitorConfiguration dmc = DiagnosticMonitor.GetDefaultInitialC onfiguration(); dmc.Logs.BufferQuotaInMB = 4; dmc.Logs.ScheduledTransferPeriod = TimeSpan.FromSeconds(30); dmc.Logs.ScheduledTransferLogLevelFilter = LogLevel.Verbose; DiagnosticMonitor.Start("Microsoft.WindowsAzure.Plugins.Diagnostics.Conne ctionString", dmc); // *** AzureAutoScale-End *** return base.OnStart(); } }

When you call the Start method of the Autoscaler class, the block will look for rule and service information, and will start to monitor hosted services and will perform the auto scaling based on the rules defined in the rule store.

Edit Autoscaling Application Block Configuration


You can add ad edit the Autoscaling application block configuration using Enterprise Library Configuration tool. To install the Enterprise Library Configuration tool, do the following steps 1. In Visual Studio, on the Tools menu, click Extension Manager. 2. In the Extension Manager dialog, click Online Gallery, and then in the Search Online Gallery box, type Enterprise Library Config. 3. Make sure that you can see version 5.0.505 of the EnterpriseLibrary.Config package. Then click the Download button. 4. Read the license and then click Install. 5. Click the Restart Now button to restart Visual Studio and complete the installation. To edit the Autoscaling application block configuration using Enterprise Library Configuration tool, right click on the app.config file in the project that will be hosting the block and click Edit configuration file.

Improving Operational Agility and Efficiency involved in Load Balancing and Scaling using Windows Azure

In the Enterprise Library Configuration tool, open the Blocks menu, and then click Add Autoscaling Settings.

Improving Operational Agility and Efficiency involved in Load Balancing and Scaling using Windows Azure

10

The enterprise library configuration tool allows editing Autoscaling settings, Rule store information and the Service information store. The Rule Store settings contain the storage information about Rules configuration file and the Service Information Store settings contain the storage information about Service configuration file. Typically, if you host the Autoscaling Application Block in a worker role, you will store the data points, rule definitions, and service information in Windows Azure storage.

Improving Operational Agility and Efficiency involved in Load Balancing and Scaling using Windows Azure

11

Author Rule Configuration File


The rule configuration file contains the rules that will be used for the scaler to scale up and scale down the hosted service. There are two types of rules available in the Autoscaling Application Block constraint rules and reactive rules. Constraint rules are associated with a time table and reactive rules are associated with KPI and conditions. The below code block shows the sample rule configuration which contains both constraint rules and reactive rules.
<?xml version="1.0" encoding="utf-8"?> <rules xmlns="http://schemas.microsoft.com/practices/2011/entlib/autoscaling/rules"> <constraintRules> <rule name="default" description="default" rank="1" enabled="true"> <actions> <range target="WebRole1" min="1" max="4"/> </actions> </rule> <rule name="peakbusinesstime" enabled="true" rank="100"> <timetable duration="02:00:00" startTime="13:26:00" utcOffset="-07:00"> <weekly days ="Friday"/> </timetable> <actions> <range target="WebRole1" min="4" max="8"/> </actions> </rule> </constraintRules> <reactiveRules> <rule name="Too Much CPU" enabled="true"> <when> <greaterOrEqual operand="CPU_Last_15Minutes" than="60"/> </when> <actions> <scale target="WebRole1" by="2" /> </actions> </rule> <rule name="Too Less CPU" enabled="true"> <when> <lessOrEqual operand="CPU_Last_15Minutes" than="30"/> </when> <actions> <scale target="WebRole1" by="-2" /> </actions> </rule> </reactiveRules> <operands> <performanceCounter alias="CPU_Last_15Minutes" performanceCounterName="\Processor (_Total)\% Processor Time" source="HighCPUWorkerRole" aggregate="Average" timespan="0 0:15:00"/> </operands> </rules>

Improving Operational Agility and Efficiency involved in Load Balancing and Scaling using Windows Azure

12

The above rule configuration contains two constraint rules a default rule and a rule for peak business time on every Fridays. The rank specified in the rule configuration is just a priority for each role. The utcOffset value is using to convert the configured local time to UTC time using by the Windows Azure. The reactive rules contain the rules for KPI based on the CPU utilization.

Author Service Configuration File


The service configuration file contains the information for Windows Azure subscriptions and hosted service(s) to monitoring for auto scaling. This tells the Scaler that which hosted service(s) should monitor. The below code blocks show the sample service configuration file.
<?xml version="1.0" encoding="utf-8" ?> <serviceModel xmlns="http://schemas.microsoft.com/practices/2011/entlib/autoscaling/s erviceModel"> <subscriptions> <subscription name="something" subscriptionId="b5fb8dfb-3e0b-xxxx-xxxx-xxxxxxxxxxxx" certificateStoreLocation="LocalMachine" certificateStoreName="My" certificateThumbprint="FE5EB4279BC6354xxxxxxxxxxxxxxxxxxxxxxxxx"> <services> <service name="myHostedServiceName" slot="Staging"> <roles> <role name="WebRole1" roleName="WebRole1" wadStorageAccountName="wadStorageAccount"/> </roles> </service> </services> <storageAccounts> <storageAccount name="wadStorageAccount" connectionString="DefaultEndpointsProtocol =https;AccountName=myaccount;AccountKey=123xxxxxxxxx"> </storageAccount> </storageAccounts> </subscription> </subscriptions> </serviceModel>

Quick Steps to Add and Use Autoscaling Application Block


The following are the major quick steps to add and use Autoscaling Application Block 1. 2. 3. 4. Add a reference to Autoscaling Application Block in host application. Instantiates the Autoscaler class and call its start method for monitoring. Edit app.config file of the host application using Enterprise Library configuration tool. Configure the Autoscaling settings.

Improving Operational Agility and Efficiency involved in Load Balancing and Scaling using Windows Azure

13

5. Configure the Rule Store settings to specify the storage information of Rules configuration file. 6. Configure the Service Information Store to specify the storage information of Service information configuration file. 7. Add Rules configuration XML file to specify the rules and conditions for scaling. 8. Add Service information XML file to specify Windows Azure subscription and hosted services to monitoring the Autoscaling Application Block.

Windows Azure Compute Resources to Host Autoscaling Application Block


The following compute resources are the essential components to host Autoscaling block 1. Windows Azure hosted service for Worker Role to host Autoscaling block. 2. BLOB storage account for store rule configuration and service information configuration.

Conclusion
Windows Azure is Microsofts offering for Cloud computing to help customers to build and deploy applications on a Pay-per-use basis and providing on-demand scalability. This allows the customers to fully focus on their applications rather than managing IT infrastructure. The Windows Azure Autoscaling Application Block lets the Windows Azure customers to take full advantage of scalability offerings provided by Windows Azure. This enables the customers to reduce number of management overheads involved load balancing and scaling which will improve the business agility and can also reduce cost and time.

Links
Windows Azure - http://www.microsoft.com/windowsazure/ Microsoft Patterns & Practice - http://entlib.codeplex.com/

S-ar putea să vă placă și