[erlang-questions] How to Name Concurrency Patterns
Fri Feb 21 10:22:53 CET 2014
We (Jesper and me) are actually working on describing common concurrency patterns for
Still WIP, but I have attached one of them - Tuple Space Storage.
We are using Object-Process Methodology for the diagrams - it is the only thing that
I have found that allows me to describe Erlang architecture without throwing up.
Don't even try to mention UML here!
Others on the backlog:
* Supervisor - you would be surprised how many moving parts this one has!
* Manager/Worker - both a simple and a more complex one.
* Pool as limited resource - more or less poolboy.
* Pool as (cache|time limited resource|round-robin|best-of-2) - a number of those
will be added later .
The idea is to document some of the common concurrency patterns in Erlang and explain
how error handling is addressed by the pattern.
Main audience is people trying to learn what is going on. For most of you super
Erlangers here it will be trivial information, but when one is trying to push Erlang
into big companies it is necessary to have material like this that can explain what
is going on in Erlang.
As you can see from the attachment we are trying to follow a description style
similar to what the OO world is using.
But we are not aiming to translate all the patterns from the OO world - we want to
document good concurrency patterns in Erlang.
If people are interested in helping out I can open up the repo we have for this.
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 172327 bytes
Desc: not available
-------------- next part --------------
> 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
> 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
> 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
> What should this be called? "Pool of workers"
> There seem to be things with well-known names "Load-balancer" "map-reduce"
> 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.
> erlang-questions mailing list
Erlang Solutions Ltd.
Tel: +45 25 14 05 38
More information about the erlang-questions