Windows Azure: can I change the number of worker role instances when the application is running in the cloud

Can I change the number of worker role instances while the application is running.

I created an application that executes a sequence of code in parallel several times depending on the user request. Say, if the user asks for a result that will be very accurate, then I will have to run the code for 1000 or more times in parallel on different data sets. If the user does not request the result to be accurate, then I will run the code 5 times in parallel. This sequence of code is performed by a working role. I launched my application with the number of working role instances equal to 5. If the user requests the result very accurately, then I can increase the number of working role instances to say 20. As soon as the request is complete, I will return the instance count by 5.

Can I do it. How can i do this. Will the application restart if I do this.

+3
source share
3 answers

Yes you can do it. Windows Azure provides a management API to perform tasks as providing and eliminating additional work roles.

You can check the autoscaling interfaces of the Lokad.Cloud project: http://code.google.com/p/lokad-cloud/wiki/AutoScaling

As part of QueueService or ScheduledService, you can access CloudService.Providers.Provisioning, which will give you programmatic access to the cloud structure to adjust the number of workers working for your application.

+3
source

, Autoscaling (Wasabi) . . http://aka.ms/autoscaling:

+1

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

Primarily:

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.");
0
source

Source: https://habr.com/ru/post/1753006/


All Articles