by danielovichdk · 3y ago · 0 comments
Difficult patterns to optimize for is my experience if any IO or network boundaries are in play. Even that and it sometimes seems the more knowledge on how threading works on one particular cpu architecture.
So for me at least, on a high level these patterns seem easy enough and seems to play well in to the popculcural small service fad and large data processing. But be aware of the underlying cpu architecture and threading and how thread pools work on your particular OS.
Oh yes and then comes the debugging and reading the code part, which we all know are where the real efforts of time comes to play.
Use these when absolutely no other options are available. Just like multithreading.
Noob question: Can 90%+ of the "effect" from the above not be replicated or be done with Go-Lang's CSP (or another language that also uses CSP) ?
Is Golang or CSP model perfect ? Of course not, but It it is "relatively" easy to reason about compared to "catalogue of other options" ?
var task2 = service.DispatchSecond(param2);
var final = service.DispatchThird(await task1, await task2);
or
var queries = users.Select(user => FetchPurchases(user.Id));
var results = await Task.WhenAll(queries);
Very easy.
As long as you don't touch System.Threading.Tasks.Dataflow namespace, everything will be good.