What is the best way to query data in Azure Service Fabric?

What is the best way to query data in Azure Service Fabric? Is there anything on top of a reliable dictionary? For example: map / reduce?

Example: A client object is stored in a trusted collection. The key is CustomerID. And now I like to find all the customers with a last name that starts with β€œA”, which come from β€œSydney” and have ordered something in the last month.

What is the best way to implement this request within the Azure Service Fabric? What would the performance look like? Suppose there are several hundred thousand customers on the list.

+5
source share
1 answer

Trusted collections are IEnumerable (or support for creating counters) similar to single-machine .NET collections, which means you can query them using LINQ. For instance:

IReliableDictionary<int, Customer> myDictionary = await this.StateManager.GetOrAddAsync<IReliableDictionary<int, Customer>>("mydictionary"); return from item in myDictionary where item.Value.Name.StartsWith("A") orderby item.Key select new ResultView(...); 

Performance depends on what request you are executing, but one of the main advantages of Reliable Collections is that they are local to the code that executes the request, that is, you read directly from memory, rather than making a network request to external storage.

With a very large dataset, you end up sharing a service that contains a dictionary (a built-in function in Service Fabric). In this case, you will have the same query in each section, but then you will need to aggregate the results. Usually in this case it is useful to set up another dictionary, which can act as an index for general queries.

+5
source

Source: https://habr.com/ru/post/1241131/


All Articles