[erlang-questions] How to Name Concurrency Patterns

Ulf Wiger ulf@REDACTED
Thu Feb 20 08:58:13 CET 2014

Perhaps it should be called "concurrency-oriented patterns" instead? Strictly speaking, a pipe isn't about concurrency so much as serialization/chaining (and can be executed without any concurrency at all), but it's most likely used more often than not in conjunction with concurrency.

A pattern I don't see mentioned often is what I might call 'orchestrator', where one process is assigned the responsibility for the overall 'script', dispatches tasks to workers and collects the results. I would say that pmap() is a simple orchestrator pattern, and a good opportunity to explain both supervision and selective receive.

Ulf W

Ulf Wiger, Feuerlabs, Inc.

> 19 feb 2014 kl. 22:14 skrev Joe Armstrong <erlang@REDACTED>:
> Hello, I'm giving a course in distributed and parallel programming in
> Erlang ...
> Next week I'll be talking about common concurrency patterns, I was
> talking with the course adviser, and I rattled off the names of a few
> concurrency patterns that were well-known and easy to explain. I said
> I'll do PUB-SUB, pipeline, map-reduce, parallel map, and so on.
> At this stage the course adviser said that a) things like PUB-SUB
> would not be familiar to the students and that b) It would take more
> than 5-10 minutes to explain PUB_SUB.
> At this stage I thought "pity these patterns don't have well-known
> names".
> What I'd like is to make a catalog of "well-known" concurrency
> patterns.  I'd like to name them, and describe them informally, and
> give the example code in Erlang.
> For example, here's how I might describe PUB-SUB.
> == PUB-SUB
>    - There are a number of named channels
>    - You can post messages to a channel ie Publish the message (the PUB)
>    - You can subscribe to a channel (The SUB)
>    - If you are currently subscribed to a channel you will be sent all messages
>      sent to the channel.
> A rudimentary version of this is about 25 lines of Erlang. A full
> version with load balancing, removing bottlenecks etc. would be a lot
> longer, but that's not the point. The basic concurrent structure can
> be explained in a few lines and named.
> Pipeline is another example: The output of the first process is the
> input to the next process and so on...
> Now I start having problems.
> Suppose I want to generalize a regular map. 
> To be precise. Suppose map(F, L) means [F(I) || I <- L]
> pmap(F, L) is parallel map (easy) all the F(I)'s are computed concurrently.
> pmap(F, L, Max) behaves like map(F,L) with at most Max F(I)'s computed concurrently.
> What should this be called? "Pool of workers"
> There seem to be things with well-known names "Load-balancer" "map-reduce" etc.
> Then there are things that we know of but that are not named. For
> example my DNS resolver has two DNS names DNS1 and DNS2.  If DNS1 is
> broken the resolver tries DNS2 - what is concurrency pattern called
> (Pool of responders) or what?
> The other day I suggested that for fault tolerance it was much easier
> to let the client go to multiple machines rather than use an expensive
> load balancer and fail-over system on the server - but there was no
> convenient name to capture this idea.
> There sees to be no accepted terminology here - so I'd appreciate any
> suggestions you have as to the names of common currency patterns that
> you use together with definitions of what the names mean.
> Cheers
> /Joe
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions

More information about the erlang-questions mailing list