Let's say, I'm using Azure Service Fabric Stateful Service, with RemotingV2, and I want to store users phone numbers (That's the only thing my service does).

Task StoreNumber(string username, string phoneNumber);
Task<string> GetNumber(string username);

I want to use the username for partitioning.

What's the elegant way to do that?

can I remove the username parameter from the methods and somehow get it from the request?

Is there a better way?


1 Answers

LoekD On Best Solutions

Here's a video that covers this subject and here's a working code sample that goes with it.

  • use a (proper e.g. FNV) hash algorithm to get the hash of username, use the long result to determine an Int64RangePartition by its key.
  • use a gateway that does the hashing for you (e.g. api management, or a custom stateless service) and forwards the call
  • you could use customer headers to pass the username. (the sample doesn't)