3

Can I be able to change the instances count of a worker role while the application is running.

I have created an application which executes a sequence of code parallely a number of times depending on the user's query. Say, If user request the result to be very accurate, then I will have to run the code for 1000 or more times parallely on different datasets. If user doesn't request the result to be accurate, then I will run the code for 5 times parallely. This sequence of code is executed by a worker role. I will start the my application with the instances count of a worker role to be 5. If the user request the result to be very accurate, then can I increment the instances count of the worker role to say 20. Once the request is finished, I will set the instances count back to 5.

Can I do this. How can I do this. Will the application gets restarted if I do this.

Md Farid Uddin Kiron
  • 16,817
  • 3
  • 17
  • 43
veda
  • 6,416
  • 15
  • 58
  • 78

3 Answers3

3

Yes, you can do this. Windows Azure exposes management API to perform tasks as provisioning and deprovisioning additional worker roles.

You could check out Auto-scaling interfaces of Lokad.Cloud project: http://code.google.com/p/lokad-cloud/wiki/AutoScaling

Within a QueueService or a ScheduledService, you can access the property CloudService.Providers.Provisioning which will grant you a programmatic access to cloud fabric in order to adjust the number of workers running for your application.

Rinat Abdullin
  • 23,036
  • 8
  • 57
  • 80
1

Yes, you can also configure the Autoscaling Application Block (Wasabi) to do that for you. For more info, see this reponse and http://aka.ms/autoscaling:

Community
  • 1
  • 1
Grigori Melnik
  • 4,067
  • 2
  • 34
  • 40
0

You could also use the information from this: http://blog.maartenballiauw.be/post/2011/03/21/Windows-Azure-and-scaling-how-(NET).aspx

Mainly:

var deployment = GetWindowsAzureDeployment();

            string configurationXml = ServiceManagementHelper.DecodeFromBase64String(deployment.Configuration);

            Log.Info("Updating configuration value...");

            var serviceConfiguration = XDocument.Parse(configurationXml);

            serviceConfiguration
                    .Descendants()
                    .Single(d => d.Name.LocalName == "Role" && d.Attributes().Single(a => a.Name.LocalName == "name").Value == RoleName)
                    .Elements()
                    .Single(e => e.Name.LocalName == "Instances")
                    .Attributes()
                    .Single(a => a.Name.LocalName == "count").Value = newInstanceCount.ToString();

            var changeConfigurationInput = new ChangeConfigurationInput();
            changeConfigurationInput.Configuration = ServiceManagementHelper.EncodeToBase64String(serviceConfiguration.ToString(SaveOptions.DisableFormatting));

            Log.Info("Uploading new configuration...");

            ManagementClient.ChangeConfigurationBySlot(SubscriptionId, ServiceName, Slot, changeConfigurationInput);

            Log.Info("Finished uploading new configuration.");
Dragos Durlut
  • 8,018
  • 10
  • 47
  • 62