在 Azure 认知搜索中调整容量Adjust capacity in Azure Cognitive Search

预配搜索服务和锁定特定的定价层之前,请花几分钟时间了解服务中的副本和分区的角色,以及如何调整服务来适应资源需求的高峰和低谷。Before provisioning a search service and locking in a specific pricing tier, take a few minutes to understand the role of replicas and partitions in a service and how you might adjust a service to accommodate spikes and dips in resource demand.

容量是所选层(层确定硬件特征)以及预期工作负荷所需的副本和分区组合的一个功能因素。Capacity is a function of the tier you choose (tiers determine hardware characteristics), and the replica and partition combination necessary for projected workloads. 增加或减少容量所需的时间为 15 分钟到几个小时,具体取决于调整的层和大小。Depending on the tier and the size of the adjustment, adding or reducing capacity can take anywhere from 15 minutes to several hours.

修改副本和分区的分配时,建议使用 Azure 门户。When modifying the allocation of replicas and partitions, we recommend using the Azure portal. 该门户针对允许的组合强制实施限制,使其低于层的上限。The portal enforces limits on allowable combinations that stay below maximum limits of a tier. 但是,如果需要使用基于脚本或基于代码的预配方法,Azure PowerShell管理 REST API 是替代的解决方案。However, if you require a script-based or code-based provisioning approach, the Azure PowerShell or the Management REST API are alternative solutions.

术语:副本和分区Terminology: replicas and partitions

分区Partitions 为读/写操作(例如在重建或刷新索引时)提供索引存储和 I/O。Provides index storage and I/O for read/write operations (for example, when rebuilding or refreshing an index). 每个分区提供总体索引的一个份额。Each partition has a share of the total index. 如果分配三个分区,则索引将划分为三个部分。If you allocate three partitions, your index is divided into thirds.
副本Replicas 是搜索服务的实例,主要用于对查询操作进行负载均衡。Instances of the search service, used primarily to load balance query operations. 每个副本是索引的一个副本。Each replica is one copy of an index. 如果分配三个副本,则可以使用索引的三个副本来为查询请求提供服务。If you allocate three replicas, you'll have three copies of an index available for servicing query requests.

何时添加节点When to add nodes

最初为服务分配了由一个分区和一个副本组成的最低级别的资源。Initially, a service is allocated a minimal level of resources consisting of one partition and one replica.

单个服务必须具有足够的资源才能处理所有工作负荷(索引和查询)。A single service must have sufficient resources to handle all workloads (indexing and queries). 没有任何工作负荷在后台运行。Neither workload runs in the background. 如果查询请求在性质上不频繁,则可以计划索引编制,但如果不这样做,服务也不会排定任务的优先级。You can schedule indexing for times when query requests are naturally less frequent, but the service will not otherwise prioritize one task over another. 此外,在内部更新服务或节点时,一定程度的冗余也会销蚀查询性能。Additionally, a certain amount of redundancy smooths out query performance when services or nodes are updated internally.

根据惯例,搜索应用程序所需的副本数往往多过分区数,尤其是在服务操作偏向于查询工作负荷的情况下。As a general rule, search applications tend to need more replicas than partitions, particularly when the service operations are biased toward query workloads. 高可用性部分将解释原因。The section on high availability explains why.


添加更多的副本或分区会增加运行服务的成本,并可能在结果的排序方式上引入细微变化。Adding more replicas or partitions increases the cost of running the service, and can introduce slight variations in how results are ordered. 请务必查看定价计算器来了解添加更多节点对计费造成的影响。Be sure to check the pricing calculator to understand the billing implications of adding more nodes. 以下图表可帮助你交叉参考特定配置所需的搜索单位数。The chart below can help you cross-reference the number of search units required for a specific configuration. 有关其他副本如何影响查询处理的详细信息,请参阅排序结果For more information on how additional replicas impact query processing, see Ordering results.

如何分配副本和分区How to allocate replicas and partitions

  1. 登录到 Azure 门户,并选择搜索服务。Sign in to the Azure portal and select the search service.

  2. 在“设置”中,打开“规模”页以修改副本和分区。 In Settings, open the Scale page to modify replicas and partitions.

    以下屏幕截图显示了预配有一个副本和分区的标准服务。The following screenshot shows a standard service provisioned with one replica and partition. 底部的公式指示正在使用多少个搜索单位 (1)。The formula at the bottom indicates how many search units are being used (1). 如果单位价格为 $100(非实际价格),则运行此服务的每月成本平均为 $100。If the unit price was $100 (not a real price), the monthly cost of running this service would be $100 on average.

    显示当前值的“规模”页Scale page showing current values

  3. 使用滑块增加或减少分区数。Use the slider to increase or decrease the number of partitions. 底部的公式指示正在使用多少个搜索单位。The formula at the bottom indicates how many search units are being used.

    此示例各使用一个副本和分区将容量翻倍。This example doubles capacity, with two replicas and partitions each. 请注意搜索单位计数;现在有 4 个搜索单位,因为计费公式是副本数乘以分区数 (2 x 2)。Notice the search unit count; it is now four because the billing formula is replicas multiplied by partitions (2 x 2). 将容量翻倍不仅仅会使运行服务的成本翻倍。Doubling capacity more than doubles the cost of running the service. 如果搜索单位的成本是 $100,则新的每月费用将是 $400。If the search unit cost was $100, the new monthly bill would now be $400.

    有关每个层的当前单位成本,请访问定价页For the current per unit costs of each tier, visit the Pricing page.

    添加副本和分区Add replicas and partitions

  4. 单击“保存”以确认所做的更改。 Click Save to confirm the changes.

    确认对规模和计费所做的更改Confirm changes to scale and billing

    更改容量需要花费几个小时才能完成。Changes in capacity take several hours to complete. 一旦启动更改过程,就无法将其取消;系统不会实时监视副本和分区的调整。You cannot cancel once the process has started and there is no real-time monitoring for replica and partition adjustments. 但是,在更改过程中,会一直显示以下消息。However, the following message remains visible while changes are underway.

    门户中的状态消息Status message in the portal


预配服务后,无法升级到更高的层。After a service is provisioned, it cannot be upgraded to a higher tier. 必须在新层中创建搜索服务,并重新加载索引。You must create a search service at the new tier and reload your indexes. 有关服务预配的帮助,请参阅在门户中创建 Azure 认知搜索服务See Create an Azure Cognitive Search service in the portal for help with service provisioning.

此外,分区和副本是由服务在内部专门管理的。Additionally, partitions and replicas are managed exclusively and internally by the service. 不存在处理器关联或者将工作负荷分配到特定节点的概念。There is no concept of processor affinity, or assigning a workload to a specific node.

分区和副本组合Partition and replica combinations

“基本”服务可以包含一个分区以及最多三个副本,上限为三个 SU。A Basic service can have exactly one partition and up to three replicas, for a maximum limit of three SUs. 唯一可调整的资源是副本。The only adjustable resource is replicas. 至少需要两个副本才能实现查询的高可用性。You need a minimum of two replicas for high availability on queries.

所有“标准”和“存储优化”搜索服务可以采用副本和分区的以下组合,但不能超过 36 个 SU 的限制。All Standard and Storage Optimized search services can assume the following combinations of replicas and partitions, subject to the 36-SU limit.

1 个分区1 partition 2 个分区2 partitions 3 个分区3 partitions 4 个分区4 partitions 6 个分区6 partitions 12 个分区12 partitions
1 个副本1 replica 1 个 SU1 SU 2 SU2 SU 3 SU3 SU 4 SU4 SU 6 SU6 SU 12 SU12 SU
2 个副本2 replicas 2 SU2 SU 4 SU4 SU 6 SU6 SU 8 SU8 SU 12 SU12 SU 24 SU24 SU
3 个副本3 replicas 3 SU3 SU 6 SU6 SU 9 SU9 SU 12 SU12 SU 18 SU18 SU 36 个 SU36 SU
4 个副本4 replicas 4 SU4 SU 8 SU8 SU 12 SU12 SU 16 SU16 SU 24 SU24 SU 不适用N/A
5 副本5 replicas 5 SU5 SU 10 SU10 SU 15 SU15 SU 20 SU20 SU 30 SU30 SU 不适用N/A
6 个副本6 replicas 6 SU6 SU 12 SU12 SU 18 SU18 SU 24 SU24 SU 36 个 SU36 SU 不适用N/A
12 副本12 replicas 12 SU12 SU 24 SU24 SU 36 个 SU36 SU 不适用N/A 不适用N/A 不适用N/A

Azure 网站上详细说明了 SU、定价和容量。SUs, pricing, and capacity are explained in detail on the Azure website. 有关详细信息,请参阅 Pricing Details(定价详细信息)。For more information, see Pricing Details.


副本数和分区数必须能被 12 整除(具体而言,为 1、2、3、4、6、12)。The number of replicas and partitions divides evenly into 12 (specifically, 1, 2, 3, 4, 6, 12). 这是因为,Azure 认知搜索将每个索引预先分割为 12 个分片,以便将其平均分散到所有分区。This is because Azure Cognitive Search pre-divides each index into 12 shards so that it can be spread in equal portions across all partitions. 例如,如果服务有三个分区,而你创建了新索引,则每个分区将包含该索引的四个分片。For example, if your service has three partitions and you create an index, each partition will contain four shards of the index. Azure 认知搜索为索引分片的方法属于实现细节,在将来的版本中可能发生变化。How Azure Cognitive Search shards an index is an implementation detail, subject to change in future releases. 尽管目前的分区数为 12,但请不要料想将来该数字永远都是 12。Although the number is 12 today, you shouldn't expect that number to always be 12 in the future.

高可用性High availability

由于扩展的过程比较简单而且相对较快,因此我们通常建议从一个分区以及一个或两个副本开始,并随着不断构建查询卷而进行扩展。Because it's easy and relatively fast to scale up, we generally recommend that you start with one partition and one or two replicas, and then scale up as query volumes build. 查询工作负荷主要是在副本上运行。Query workloads run primarily on replicas. 如果需要更高的吞吐量或高可用性,也许需要增加副本。If you need more throughput or high availability, you will probably require additional replicas.

针对高可用性的一般建议是:General recommendations for high availability are:

  • 对于只读工作负荷(查询),需要有两个副本才能实现高可用性Two replicas for high availability of read-only workloads (queries)

  • 对于读/写工作负荷(查询以及添加、更新或删除单个文档时的索引编制),需有三个或更多个副本才能实现高可用性Three or more replicas for high availability of read/write workloads (queries plus indexing as individual documents are added, updated, or deleted)

Azure 认知搜索的服务级别协议 (SLA) 针对查询操作,以及由文档添加、更新或删除操作构成的索引更新。Service level agreements (SLA) for Azure Cognitive Search are targeted at query operations and at index updates that consist of adding, updating, or deleting documents.

基本层最多能有一个分区和三个副本。Basic tier tops out at one partition and three replicas. 如果希望灵活地立即响应对索引编制和查询吞吐量的需求波动,请考虑使用标准层中的一个。If you want the flexibility to immediately respond to fluctuations in demand for both indexing and query throughput, consider one of the Standard tiers. 如果你发现存储要求的增长速度大大超过了可用的吞吐量,请考虑使用某个“存储优化”层。If you find your storage requirements are growing much more rapidly than your query throughput, consider one of the Storage Optimized tiers.

灾难恢复Disaster recovery

目前没有任何内置的机制可实现灾难恢复。Currently, there is no built-in mechanism for disaster recovery. 添加分区或副本并不是实现灾难恢复目标的正确策略。Adding partitions or replicas would be the wrong strategy for meeting disaster recovery objectives. 最常见的方法是通过在另一区域中设置另一个搜索服务,在服务级别添加冗余。The most common approach is to add redundancy at the service level by setting up a second search service in another region. 与索引重建期间的可用性一样,重定向或故障转移逻辑必须来自代码。As with availability during an index rebuild, the redirection or failover logic must come from your code.

评估副本Estimate replicas

在生产服务中,应分配三个副本来满足 SLA 的要求。On a production service, you should allocate three replicas for SLA purposes. 如果遇到查询性能缓慢的问题,可以添加副本,使更多的索引副本联机,以支持更大的查询工作负荷,并通过多个副本对请求进行负载均衡。If you experience slow query performance, you can add replicas so that additional copies of the index are brought online to support bigger query workloads and to load balance the requests over the multiple replicas.

我们不会提供有关需要多少个副本来适应查询负载的指导。We do not provide guidelines on how many replicas are needed to accommodate query loads. 查询性能取决于查询复杂性和争用资源的工作负荷。Query performance depends on the complexity of the query and competing workloads. 尽管添加副本会明显提高性能,但结果不一定有线性改善:添加三个副本并不保证带来三倍的吞吐量。Although adding replicas clearly results in better performance, the result is not strictly linear: adding three replicas does not guarantee triple throughput.

有关评估解决方案的 QPS 的指导,请参阅性能缩放监视查询For guidance in estimating QPS for your solution, see Scale for performanceand Monitor queries

评估分区Estimate partitions

所选的层确定了分区大小和速度,每个层已根据一组适合不同方案的特征进行优化。The tier you choose determines partition size and speed, and each tier is optimized around a set of characteristics that fit various scenarios. 如果选择更高端的层,所需的分区数可能比使用 S1 时更少。If you choose a higher-end tier, you might need fewer partitions than if you go with S1. 需要通过自我引导式测试解答的一个问题是,对于性能而言,使用更大且更昂贵的分区,是否比在较低层上预配的服务中使用两个更廉价的分区更好。One of the questions you'll need to answer through self-directed testing is whether a larger and more expensive partition yields better performance than two cheaper partitions on a service provisioned at a lower tier.

需要以近乎实时的速度刷新数据的搜索应用程序,需要的分区数在比例上要多于副本。Search applications that require near real-time data refresh will need proportionally more partitions than replicas. 添加分区可将读/写操作分配到更多的计算资源。Adding partitions spreads read/write operations across a larger number of compute resources. 此外,还能提供更多磁盘空间来存储更多的索引和文档。It also gives you more disk space for storing additional indexes and documents.

索引越大,查询所需的时间就越长。Larger indexes take longer to query. 因此,可能发现,每次增加分区都需要按比例少量增加副本。As such, you might find that every incremental increase in partitions requires a smaller but proportional increase in replicas. 查询和查询卷的复杂性影响查询执行的速度。The complexity of your queries and query volume will factor into how quickly query execution is turned around.

后续步骤Next steps