Windows Azure:我可以在应用程序在云上运行时更改辅助角色的实例数

问题描述 投票:3回答:3

我可以在应用程序运行时更改辅助角色的实例数。

我创建了一个应用程序,它根据用户的查询并行执行一系列代码。说,如果用户要求结果非常准确,那么我将不得不在不同的数据集上并行运行代码1000次或更多次。如果用户没有要求结果准确,那么我将平行运行代码5次。这段代码由worker角色执行。我将启动我的应用程序,其中一个辅助角色的实例数为5.如果用户请求结果非常准确,那么我可以将辅助角色的实例数增加到20个。一旦请求完成,我将实例数设置为5。

我能这样做吗我怎样才能做到这一点。如果我这样做,应用程序是否会重新启动。

azure azure-worker-roles
3个回答
3
投票

是的,你可以这样做。 Windows Azure公开管理API以执行配置和取消配置其他工作者角色的任务。

您可以查看Lokad.Cloud项目的自动缩放界面:http://code.google.com/p/lokad-cloud/wiki/AutoScaling

在QueueService或ScheduledService中,您可以访问属性CloudService.Providers.Provisioning,该属性将授予您对云结构的编程访问权限,以便调整为您的应用程序运行的工作程序数。


1
投票

是的,您还可以配置自动缩放应用程序块(Wasabi)来为您执行此操作。有关更多信息,请参阅此reponsehttp://aka.ms/autoscaling


0
投票

您还可以使用以下信息:http://blog.maartenballiauw.be/post/2011/03/21/Windows-Azure-and-scaling-how-(NET).aspx

主要是:

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.");
© www.soinside.com 2019 - 2024. All rights reserved.