如何消除 Azure 搜索服务 API 限制
How to eliminate Azure Search Service API Throttling
我们的目标是完全消除 Azure 搜索服务限制。最初,我们从 S1 层上的 3 个副本和 1 个分区开始。我们遇到了很多限制,有时甚至高达 1.5% 的请求都受到了限制。我们采取了一些措施来缓解这个问题:
1) - 我们开始对服务进行负载测试,并得出了 3 个副本的基线 req/sec。每次我们达到 ~37 req/sec 我们的服务都会受到限制。
2)- 我们不希望我们的用户看到错误,为了缓解这个问题,我们实施了指数退避瞬时故障策略,当 Azure 搜索 API returns a 5xx 或时重试调用408(请求超时)响应。这对我们很有效。
3)问题依旧;我们仍然在 37 req/sec 处受到限制,这对我们来说似乎很低。这意味着我们大致得到每个副本的 MAX ~12 req/sec
。因此,我们对查询进行了性能调整(从索引中删除了分面、高基数字段,清理了字段属性并确保索引处于最低限度)我们的查询速度更快了一点,并且对节流前端没有太大影响。
4) 所以我们决定增加到五个副本以摆脱限制。我们再次进行了负载测试,现在该服务可以处理 ~59 req/secs 基线。这又变成了每个副本~12 requests/sec
~12 requests/sec
每个副本似乎是标准层服务器的低容量。这对我们来说是个大问题,因为我们的流量只会增加(更不用说处理讨厌的机器人流量)
Azure 搜索团队认为这些基准数据正确吗?
还是我们做错了什么?如果需要,我可以提供搜索查询。
如有任何帮助,我们将不胜感激!
谢谢!
Azure 搜索中的缩放是一个复杂的主题。我推荐以下内容:
- 评论Deployment strategies and best practices for optimizing performance on Azure Search
-
Azure Search does not run indexing tasks in the background. If your service handles query and indexing workloads concurrently, take this into account by either introducing indexing jobs into your query tests, or by exploring options for running indexing jobs during off peak hours.
如果您在查询的同时运行索引作业,请考虑在非高峰时段运行它们或进一步增加规模
- 您提到您觉得每秒 12 个请求的请求率太低了。您似乎已经采取了性能优化页面上列出的一些步骤,包括从索引中删除高基数字段。我怀疑您的个人查询速度很慢,您会考虑增加您拥有的分区数量吗?
来自Scaling for slow individual queries:
A partition is a mechanism for splitting your data across extra resources. Adding a second partition splits data into two, a third partition splits it into three, and so forth. One positive side-effect is that slower queries sometimes perform faster due to parallel computing. We have noted parallelization on low selectivity queries, such as queries that match many documents, or facets providing counts over a large number of documents. Since significant computation is required to score the relevancy of the documents, or to count the numbers of documents, adding extra partitions helps queries complete faster.
如果您分享查询、示例记录的外观以及索引中有多少条记录,我们可以提供更详细的建议。
感谢马修的详细回复!
1) 我们遵循了此处提到的策略:Deployment strategies and best practices for optimizing performance on Azure Search
2) 我们考虑过 运行 在 Off-peak 小时内建立索引器,但我们的用例需要我们更频繁地 运行 我们的索引(设置为 运行每 15 分钟)
3) 是的,我们的查询可能有点复杂。
索引大小:160K 行;
字段数:108
这是我们的着陆页中的示例查询:
"$count=false&facet=IsUsed,count:500&facet=Year,count:500&facet=ChassisMake,count:500&facet=ChassisModel,count:500&facet=NormalTrim,count:500&facet=CabType,count:500&facet=RoofHeight,count:500&facet=ChassisType,count:500&facet=DriveTrain,count:500&facet=RearWheels,count:500&facet=FuelType,count:500&facet=NormalEngine,count:500&facet=NormalTransmission,count:500&facet=NormalColor,count:500&facet=GVWR,count:500&facet=Wheelbase,count:500&facet=CA,count:500&facet=BodyType,count:500&facet=BodyMake,count:500&facet=HasSnowPlow,count:500&facet=HasCrane,count:500&facet=HasVanPartition,count:500&facet=BodyLength,count:500&facet=DealerNumericID,count:2000&$filter=((search.in(CMID, '5e3c3789-bb0f-4e6a-8c8b-a0fc31568d85') ) and ( HasLiftKit eq null )) and (IsDealerLive eq true) and IsDemoDealer eq false and DepartureDate eq null and IsUsed eq false and geo.distance(GeoPoint, geography'POINT(-121.141636 38.666597)') le 80&queryType=simple&scoringParameter=IsUpfit-'true'&scoringParameter=GeoPoint-'-121.141636','38.666597'&scoringProfile=locator-distance&searchMode=any&$select=ID,DealerID,IsUsed,Featured,CustomTitle,StockNumber,CleanStockNumber,Vin,ChassisImagePathTemplate,ChassisBlobLastUpdated,BodyImagePathTemplate,BodyBlobLastUpdated,ChassisModelVINDecodingID,ChassisManufacturerID,BodyManufacturerID,BodyType_Code,ChassisMake,ChassisModel,DealerNumericID,Year,BodyTypeID,BodyType,EnabledAttributes,Mileage,CabType,DriveTrain,RearAxle,FuelType,Transmission,Color,RoofHeight,SalePrice,OnSale,SaleStartDate,SaleEndDate,SaleShowSaleBanner&$skip=0&$top=10
SearchString:*"
索引预热时该查询 运行s 在 75 毫秒内,索引未预热时在 ~300 毫秒内。
请告诉我们您的想法。
非常感谢!
我们的目标是完全消除 Azure 搜索服务限制。最初,我们从 S1 层上的 3 个副本和 1 个分区开始。我们遇到了很多限制,有时甚至高达 1.5% 的请求都受到了限制。我们采取了一些措施来缓解这个问题:
1) - 我们开始对服务进行负载测试,并得出了 3 个副本的基线 req/sec。每次我们达到 ~37 req/sec 我们的服务都会受到限制。
2)- 我们不希望我们的用户看到错误,为了缓解这个问题,我们实施了指数退避瞬时故障策略,当 Azure 搜索 API returns a 5xx 或时重试调用408(请求超时)响应。这对我们很有效。
3)问题依旧;我们仍然在 37 req/sec 处受到限制,这对我们来说似乎很低。这意味着我们大致得到每个副本的 MAX ~12 req/sec
。因此,我们对查询进行了性能调整(从索引中删除了分面、高基数字段,清理了字段属性并确保索引处于最低限度)我们的查询速度更快了一点,并且对节流前端没有太大影响。
4) 所以我们决定增加到五个副本以摆脱限制。我们再次进行了负载测试,现在该服务可以处理 ~59 req/secs 基线。这又变成了每个副本~12 requests/sec
~12 requests/sec
每个副本似乎是标准层服务器的低容量。这对我们来说是个大问题,因为我们的流量只会增加(更不用说处理讨厌的机器人流量)
Azure 搜索团队认为这些基准数据正确吗?
还是我们做错了什么?如果需要,我可以提供搜索查询。
如有任何帮助,我们将不胜感激!
谢谢!
Azure 搜索中的缩放是一个复杂的主题。我推荐以下内容:
- 评论Deployment strategies and best practices for optimizing performance on Azure Search
-
Azure Search does not run indexing tasks in the background. If your service handles query and indexing workloads concurrently, take this into account by either introducing indexing jobs into your query tests, or by exploring options for running indexing jobs during off peak hours.
如果您在查询的同时运行索引作业,请考虑在非高峰时段运行它们或进一步增加规模
- 您提到您觉得每秒 12 个请求的请求率太低了。您似乎已经采取了性能优化页面上列出的一些步骤,包括从索引中删除高基数字段。我怀疑您的个人查询速度很慢,您会考虑增加您拥有的分区数量吗?
来自Scaling for slow individual queries:
A partition is a mechanism for splitting your data across extra resources. Adding a second partition splits data into two, a third partition splits it into three, and so forth. One positive side-effect is that slower queries sometimes perform faster due to parallel computing. We have noted parallelization on low selectivity queries, such as queries that match many documents, or facets providing counts over a large number of documents. Since significant computation is required to score the relevancy of the documents, or to count the numbers of documents, adding extra partitions helps queries complete faster.
如果您分享查询、示例记录的外观以及索引中有多少条记录,我们可以提供更详细的建议。
感谢马修的详细回复!
1) 我们遵循了此处提到的策略:Deployment strategies and best practices for optimizing performance on Azure Search
2) 我们考虑过 运行 在 Off-peak 小时内建立索引器,但我们的用例需要我们更频繁地 运行 我们的索引(设置为 运行每 15 分钟)
3) 是的,我们的查询可能有点复杂。
索引大小:160K 行; 字段数:108
这是我们的着陆页中的示例查询:
"$count=false&facet=IsUsed,count:500&facet=Year,count:500&facet=ChassisMake,count:500&facet=ChassisModel,count:500&facet=NormalTrim,count:500&facet=CabType,count:500&facet=RoofHeight,count:500&facet=ChassisType,count:500&facet=DriveTrain,count:500&facet=RearWheels,count:500&facet=FuelType,count:500&facet=NormalEngine,count:500&facet=NormalTransmission,count:500&facet=NormalColor,count:500&facet=GVWR,count:500&facet=Wheelbase,count:500&facet=CA,count:500&facet=BodyType,count:500&facet=BodyMake,count:500&facet=HasSnowPlow,count:500&facet=HasCrane,count:500&facet=HasVanPartition,count:500&facet=BodyLength,count:500&facet=DealerNumericID,count:2000&$filter=((search.in(CMID, '5e3c3789-bb0f-4e6a-8c8b-a0fc31568d85') ) and ( HasLiftKit eq null )) and (IsDealerLive eq true) and IsDemoDealer eq false and DepartureDate eq null and IsUsed eq false and geo.distance(GeoPoint, geography'POINT(-121.141636 38.666597)') le 80&queryType=simple&scoringParameter=IsUpfit-'true'&scoringParameter=GeoPoint-'-121.141636','38.666597'&scoringProfile=locator-distance&searchMode=any&$select=ID,DealerID,IsUsed,Featured,CustomTitle,StockNumber,CleanStockNumber,Vin,ChassisImagePathTemplate,ChassisBlobLastUpdated,BodyImagePathTemplate,BodyBlobLastUpdated,ChassisModelVINDecodingID,ChassisManufacturerID,BodyManufacturerID,BodyType_Code,ChassisMake,ChassisModel,DealerNumericID,Year,BodyTypeID,BodyType,EnabledAttributes,Mileage,CabType,DriveTrain,RearAxle,FuelType,Transmission,Color,RoofHeight,SalePrice,OnSale,SaleStartDate,SaleEndDate,SaleShowSaleBanner&$skip=0&$top=10
SearchString:*"
索引预热时该查询 运行s 在 75 毫秒内,索引未预热时在 ~300 毫秒内。
请告诉我们您的想法。
非常感谢!