TheSugoiBoi
TheSugoiBoi

Reputation: 160

One call to Service Fabric Reliable Dictionary with multiple keys

My situation:

The problem:

The latency for each call is around 100 millseconds (I'm debugging locally if that makes any difference) but multiply that by 5000 and we're talking about minutes now.

Instead of passing keys to call my reliable dictionary over 5000 times...Can I just make ONE call to Service Fabric with multiple keys?

Upvotes: 0

Views: 1120

Answers (2)

Mert Coskun - MSFT
Mert Coskun - MSFT

Reputation: 316

It would be worth profiling latency to see where the time is spent. Two possible culprits that come to mind are

  1. Communication between the stateless front-end to stateful back-end
  2. Reliable Dictionary doing disk IO to page in values that where paged out to serve the reads.

Since you are running locally, I assume first is not a problem yet. However, batching read calls to the back-end service would be a good idea to reduce the number of round trips between your services. You can also consider having a cache for reads that do not need to come from the authoritative store. Since you control the communication, this is all in your power.

If the second is the current bottleneck, Reliable Dictionary does not expose a mechanism to batch multiple reads to reduce the number of disk IOs today. If you are willing to increase memory usage for lower latency reads, then you can use Reliable Dictionary Notifications to build an in-memory cache of the Reliable Dictionary you would like low latency reads from.

Upvotes: 0

grokk
grokk

Reputation: 1

You can use Eli Arbel's extension on IReliableDictionary https://gist.github.com/aelij/987d974c811865029564f1bbeffb6b47. Something like

      ` var data= await YouReliableDictionary;
        var values= (await data.CreateLinqAsyncEnumerable(txn))
            .Where(x => youMultipleKeys.Contains(x.Key))
            .Select(x=>x.Value)

Upvotes: 0

Related Questions