如何缩放 Azure SignalR 服务实例?How to scale an Azure SignalR Service instance?

本文介绍如何缩放 Azure SignalR 服务的实例。This article shows you how to scale your instance of Azure SignalR Service. 有两种方案可用于缩放、纵向扩展和横向扩展。There are two scenarios for scaling, scale up and scale out.

  • 纵向扩展:获取更多单位、连接、消息等。Scale up: Get more units, connections, messages, and more. 可以通过将定价层从“免费”更改为“标准”进行纵向扩展。You scale up by changing the pricing tier from Free to Standard.
  • 横向扩展:增加 SignalR 单位数。Scale out: Increase the number of SignalR units. 最多可以横向扩展到 100 个单位。You can scale out to as many as 100 units. 以下是可为缩放选择的有限单位选项:对于单个 SignalR 服务实例,可使用 1、2、5、10、20、50 和 100 个单位。There are limited unit options to select for the scaling: 1, 2, 5, 10, 20, 50 and 100 units for a single SignalR Service instance.

应用缩放设置需要花费几分钟时间。The scale settings take a few minutes to apply. 在极少数情况下,应用可能需要大约 30 分钟。In rare cases, it may take around 30 minutes to apply. 这些设置不需要更改代码或重新部署服务器应用程序。They don't require you to change your code or redeploy your server application.

有关单个 SignalR 服务的定价和容量信息,请参阅 Azure SignalR 服务定价详细信息For information about the pricing and capacities of individual SignalR Service, see Azure SignalR Service Pricing Details.

备注

将 SignalR 服务从“免费”层更改为“标准”层(或反之)会更改公共服务 IP。在整个 Internet 中将更改传播到 DNS 服务器通常需要 30-60 分钟。 Changing SignalR Service from Free tier to Standard tier or vice versa, the public service IP will be changed and it usually takes 30-60 minutes to propagate the change to DNS servers across the entire internet. 在更新 DNS 之前,服务可能不可访问。Your service might be unreachable before DNS gets updated. 一般我们不建议经常更改定价层。Generally it’s not recommended to change your pricing tier too often.

在 Azure 门户中缩放Scale on Azure portal

  1. 在浏览器中,打开 Azure 门户In your browser, open the Azure portal.

  2. 在 SignalR 服务页上的左侧菜单中,选择“缩放”。 In your SignalR Service page, from the left menu, select Scale.

  3. 选择定价层,然后单击“选择”。 Choose your pricing tier, and then click Select. 设置“标准”层的单位计数。 Set the unit count for Standard Tier.

    在门户中缩放

  4. 单击“保存” 。Click Save.

使用 Azure CLI 进行缩放Scale using Azure CLI

此脚本将创建“免费”层的新 SignalR 服务资源和新的资源组,并将此资源组纵向扩展到“标准”层。 This script creates a new SignalR Service resource of Free Tier and a new resource group, and scales it up to Standard Tier.

#!/bin/bash

# Generate a unique suffix for the service name
let randomNum=$RANDOM*$RANDOM

# Generate a unique service and group name with the suffix
SignalRName=SignalRTestSvc$randomNum
#resource name must be lowercase
mySignalRSvcName=${SignalRName,,}
myResourceGroupName=$SignalRName"Group"

# Create resource group 
az group create --name $myResourceGroupName --location chinaeast2

# Create the Azure SignalR Service resource
az signalr create \
  --name $mySignalRSvcName \
  --resource-group $myResourceGroupName \
  --sku Free_F1 \
  --service-mode Default

# Scale up to Standard Tier, and scale out to 50 units
az signalr update \
  --name $mySignalRSvcName \
  --resource-group $myResourceGroupName \
  --sku Standard_S1 \
  --unit-count 50

记下为新资源组生成的实际名称。Make a note of the actual name generated for the new resource group. 如果要删除所有组资源,将使用该资源组名称。You will use that resource group name when you want to delete all group resources.

清理部署Clean up deployment

运行示例脚本后,可以使用以下命令删除资源组以及与其关联的所有资源。After the sample script has been run, the following command can be used to remove the resource group and all resources associated with it.

az group delete --name myResourceGroup

比较定价层Compare pricing tiers

有关详细信息,例如每个定价层包含的消息和连接,请参阅 SignalR Service 定价详细信息For detailed information, such as included messages and connections for each pricing tier, see SignalR Service Pricing Details.

有关每个层中的服务限制、配额和约束表格,请参阅 SignalR 服务限制For a table of service limits, quotas, and constraints in each tier, see SignalR Service limits.

后续步骤Next steps

本指南介绍了如何缩放单个 SignalR 服务实例。In this guide, you learned about how to scale single SignalR Service instance.

缩放、分片和跨区域方案还支持多个终结点。Multiple endpoints are also supported for scaling, sharding, and cross-region scenarios.