Implications of using the AzureSearch SDK with a static dictionary 30-40 ISearchIndexClients

I have an ASP.NET web application that uses 30-40 different search indexes in 5-6 search engines (different clients are at different price levels).

I am currently building a new ISearchServiceClient instance and then the corresponding ISearchIndexClient for the specific index needed based on the client making the call.

For performance reasons, I was thinking about scheduling march servers and putting them in a Dictionary object when I run ALL ISearchIndexClients application :

public static Dictionary<String, SearchIndexClient> SearchIndexes;

      

so any particular index can be called directly from the static dictionary and used like this:

SearchIndexes["IndexName"].Documents.Search(searchText, searchParameters);

      

I hope this will speed up the refresh times of queries and indexes, especially on the "hot" index . I am concerned that this could lead to memory leaks, performance issues and other unknowns.

I have not seen examples using the statically available SearchServiceClient or SearchIndexClient , so I am a little tricky to continue this approach. My questions for the community:

  • Is my plan sound?
  • Will it actually improve performance.
  • What are the disadvantages or consequences (if any?)
  • If the number of indexes increases over time (for example, up to 60-70), then will I start to see disadvantages?
  • It would be wiser to bundle SearchServiceClients into a dictionary and connect to the corresponding SearchIndexClient from there as needed:

    public static Dictionary<String, SearchServiceClient> SearchServices;
    
    var searchIndexClient = SearchServices["ServiceName"].Indexes.GetClient("IndexName");
    searchIndexClient.Documents.Search(searchText, searchParameters);
    
          

+1


source to share


1 answer


This strategy probably won't scale for the number of indexes you want. The most likely outcome is that you run out of the pool of available TCP connections. A better approach would be to inject a SearchIndexClient

keyed instance cache by the index name. In case of a cache miss, you can get exclusive access to the last used client and call TargetDifferentIndex . This method was added SearchIndexClient

for this scenario.



You can find more discussion and background information on the impact of the exchange SearchIndexClients

on GitHub , Forums MSDN and fooobar.com/questions/2405663 / ... .

+1


source







All Articles