[erlang-questions] Best approach to creating a process/connection pool

Anton Lavrik alavrik@REDACTED
Thu Aug 4 15:59:23 CEST 2011

You may want to take a look at Poolboy, it looks pretty good:

It includes an example of pgsql connection pool.


On Thu, Aug 4, 2011 at 2:01 AM, Andrew Berman <rexxe98@REDACTED> wrote:

> I'm fairly new to Erlang and I am trying to write a process pool which
> essentially is a connection pool to a database.  I have designed the
> application like this:  The main pool gen_server has a queue of PIDs
> of gen_fsm's.  Each gen_fsm calls spawn_links a 3rd party gen_server and
> carries
> the state of the connection.  So the 3rd party gen_server and the
> gen_fsm should always live and die together.  I currently have set it
> up such that gen_fsm calls proc_lib:spawn_link() to start the 3rd
> party gen_server, but I'm wondering how this factors into the
> supervision tree.  I currently have two supervisors:
> Sup1 -> one_for_all -> 2 children: pool gen_server and Sup2
> Sup2 -> simple_one_for_one -> 1 child: gen_fsm
> So my question is: is it ok to use spawn_link instead of somehow
> trying to put the 3rd party gen_server into the supervision tree?  If
> it should go into the supervision tree, how would I organize the tree
> then such that the gen_fsm and 3rd party gen_server are reliant on
> each other?
> Thanks for any help!
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20110804/657cf8c2/attachment.htm>

More information about the erlang-questions mailing list