We're running Cloud Native .NET in Brighton, 26th-27th April 2018. High quality training for building .NET Core, distributed, production ready systems.
Throttling the Level of Concurrency in F#
Async.Parallel |> Async.RunSynchronously is great for running a load of stuff in parallel in F#, as long as you don't mind them all running at the same time.
Often, though, you want to map across a sequence and run functions on the elements in parallel, but with a limit to how many are being processed concurrently. Whether you're doing something CPU heavy and there's no point running more than the number of processors on the box, or whether you know that you'll swamp a remote server if you just dump all of your connections on it at once, this issue comes up surprisingly often.
As a first stab, you might be tempted to do something like this (if you think like I do):