Q:

Hashing to partitions within DocumentDB

I'm building a system atop DocumentDB. We're using partitioned collections. For the partition key, we're going to use a random number to best ensure that we have equal utilization of the underlying partitions (and hence, equal utilization of the RUs because RUs are split equally amongst the underlying partitions).
We'll be storing the partition key within an identifier so that we know how to "find" the document later when a request is made by the identifier.
With that said, we're trying to figure out the tradeoffs of the random number range. Our choice is something like [0-999] or [0-99] if we want to save one character (Which is important in our use case).
If there are >99 underlying partitions, we would probably be under-utilizing partitions because our distribution wouldn't cover all possible "buckets". I'm trying to reason the opposite - namely, with less than 99 physical partitions, what is the trade-off of reducing the random distribution range to [0-99]?

A:

All documents with the same partition key will be placed by DocumentDB in the same physical partition. So, the advantage of having a coarse partition key (with 99 unique buckets) is that non-primary key queries against a larger set, i.e. data with the same bucket have locality and can be queried with very low (single-digit ms) latency, just like primary key queries on bucket + ID. You also have a bigger transaction boundary, which might be important for scenarios requiring transactions. 
The disadvantage with coarse partition keys is scalability, like you mentioned in the question. Your data/throughput cannot exceed what can be supported by 99 DocumentDB partitions. Also due to the nature of hashing (https://en.wikipedia.org/wiki/Birthday_problem), you can run into skews even with a smaller number of partitions than 99. That said, if your data/throughput requirements are on the low end, 99 is a fairly reasonable number.
It would help to understand why your application needs two vs three digits. You can also reach out to the DocumentDB team at askdocdb@microsoft.com for further support/discussion. 

