[erlang-questions] Multiple db connection drivers

Michael Truog mjtruog@REDACTED
Sat Feb 18 04:46:58 CET 2012


On 02/17/2012 05:53 PM, Tim Watson wrote:
> On 16 February 2012 14:15, Erisa Dervishi <erisa85d@REDACTED> wrote:
>> Hi everybody,
>>
>> I am an erlang newbie, and I am doing a survey on existing Erlang db access
>> drivers. I am most interested in drivers that can handle and process
>> multiple concurrent db requests. Are there any working Erlang multithread db
>> access drivers for MySql or PostgreSQL? What about BerkleyDB? Or any other
>> Erlang driver that can handle db requests in parallel?
> SqlRelay is an interesting one. If you use it, just bare in mind each
> erlang port (linked to the external C program which is in turn,
> connected to one of the connection daemons) is going to communicate
> synchronously over stdio, so you'll need to do the same thing (pooling
> the ports) there I would've thought.

If you want to get more concurrency in your usage of an erlang port, you can use CloudI (http://cloudi.org) to provide a configured number of tcp connections to the local OS process (configured as the number of threads for a CloudI service running as a job).  The CloudI API would then provide some simple message passing functions to use in each thread that could interface with SqlRelay.  So, that approach could help you avoid contention, but still provide the fault-tolerance of an erlang port (i.e., avoiding the use of a port driver or NIF).

There is native Erlang code available for PostgreSQL (I agree that Will's pgsql is currently the best) and MySQL (many versions of this exist from many authors).  There is a BerkleyDB port driver in EDTK, but I am not sure how much usage it has now.  It seems best to stick with native Erlang code for database drivers, whenever possible, so that you have fault-tolerance and simpler concurrency.

- Michael




More information about the erlang-questions mailing list