[erlang-questions] Reinserting a message into a gen_server's mailbox

Ryan Zezeski rzezeski@REDACTED
Wed Aug 11 14:39:18 CEST 2010


On Wed, Aug 11, 2010 at 2:46 AM, Hynek Vychodil <hynek@REDACTED> wrote:

>
>
> I can't see any reason why this request arrived to this single
> gen_server at all. There is known anti-pattern in the linux kernel
> development named "midlayer mistake" and common advice is, if there is
> not a reason for midlayer use a library Luke. Translated to Erlang: if
> there is not a reason for process use a module Luke. I know it is
> strong temptation add some abstract layer and separate things and
> server is first thing what comes on mind in Erlang but stateless
> module often serves too. Very similar advice is written in subsection
> A Case Study on Concurrency-Oriented Programming of Chapter 4:
> Concurrent Programming of famous Cesarini and Thompson's book Erlang
> Programming (page 110). Where "high request throughput" comes from? If
> it is from already concurrent activity (web server request handler I
> guess) keep it then. I did a lot of same mistakes and will do but I
> hope I will wrap mine head around and will do it less and less in
> future.
>
>
As I thought about your response this morning I realized--you are absolutely
right!  There is no reason that I need this intermediate gen_server in my
design.  I think my reason for having it was more by accident as I evolved
the application.  Originally I had one gen_server satisfying all requests to
my app.  At some point I realized this could cause a bottle-neck if a
request was long running, so I then took my above approach.  Now, it's
obvious that I could just use a library module to achieve the same thing.

-Ryan


More information about the erlang-questions mailing list