Hashed/Sharded ActionBlocks <p>I have a constant flow of certain items that I need to process in parallel so I'm using <code>TPL Dataflow</code>. The catch is that the items that share the same key (similar to a Dictionary) should be processed in a FIFO order and not be parallel to each other (they can be parallel to other items with different values).</p> <p>The work being done is very CPU bound with minimal asynchronous locks so my solution was to create an array of <code>ActionBlock&lt;T&gt;</code>s the size of <code>Environment.ProcessorCount</code> with no parallelism and post to them according to the key's <code>GetHashCode</code> value.</p> <p>Creation:</p> <pre><code>_actionBlocks = new ActionBlock&lt;Item&gt;[Environment.ProcessorCount]; for (int i = 0; i &lt; _actionBlocks.Length; i++) { _actionBlocks[i] = new ActionBlock&lt;Item&gt;(_ =&gt; ProcessItemAsync(_)); } </code></pre> <p>Usage:</p> <pre><code>bool ProcessItem(Key key, Item item) { var actionBlock = _actionBlocks[(uint)key.GetHashCode() % _actionBlocks.Length]; return actionBlock.Post(item); } </code></pre> <p>So, my question is, is this the best solution to my problem? Am I hurting performance/scalability? Am I missing something?</p>