Wednesday, January 22, 2014

Azure auto scaling based on CPU usage tutorial

Windows Azure has come up with built in Auto Scale feature on Azure Management Portal. Azure Auto Scale block can be used to perform this however one should use auto scale feature provided on Azure Management Portal itself.
An Azure hosted worker role can be auto scaled based on number of message in the Queue storage or based on CPU usage. If suppose you wish to autoscale the azure worker role based on CPU usage then to understand how it works I created following code. The code snippet given below actually performs heavy operations on Worker Role due to which the CPU usage on Azure Worker Role VM increases. Then the following screenshot depicts that how auto scale feature can be configured from Azure Management Portal.
Following code you can put within Run method within while loop having true condition -

Then the role can be auto scaled as shown below – 

Sometime you may receive following error after configuring auto scale – “Could not automatically scale because monitoring data was not found”.

I have encountered this error. There is simple resolution to this problem. When your Role is started after deployment do not configure the auto scale immediately. Let the roles be running for atleast 15 minutes. Have look on Monitoring tab. When it shows atleast some graph for the roles present within cloud service; then you can configure auto scaling and you will not get error as “Could not automatically scale because monitoring data was not found”.

Hope this helps.
Happy Autoscaling!!!

No comments:

Post a Comment