Click here to get back home

Re: Sharing a DBI::Mysql database connection with your children

 HomeNewsGroups | Search | About
 comp.lang.perl.misc    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
Re: Sharing a DBI::Mysql database connection with your children Peter J. Holzer 03-31-2008
Posted by Peter J. Holzer on March 31, 2008, 4:57 am
Please log in for more thread options
> I have a process I was thinking of making into a multithreaded daemon
^^^^^^^^^^^^^
> that deals with a MySQL database. The thought is that the daemon would
> open the database once, then listen for clients. As clients connected
> the daemon would fork off a copy of itself and handle the requests. This
^^^^
Do you want to use threads or fork?

> would make the process faster because I wouldn't need to open the
> database every time a new client wanted service.

This cannot be done. Not only will the database server get a mixture of
requests from different database clients on the same connection (this
could be solved), but it also has to send back all replies via the same
connection: Which client will receive the response? There is no way to
determine that.

(There is at least one RDBMS where the client automatically opens a new
connection when it detects a pid change - presumably the new connection
will be pre-authenticated and faster to establish).

Your best bet is probably to use a pre-forked approach like some web
servers. Run a number of your your daemons in parallel, all listening on
the same port. A client connecting to that port will get any of them.
If all are busy, the client has to wait, or a controlling process can
start more worker processes.

        hp


Similar ThreadsPosted
Re: Sharing a DBI::Mysql database connection with your children March 31, 2008, 1:06 pm
Re: Sharing a DBI::Mysql database connection with your children March 31, 2008, 2:08 pm
Database Connection Problem June 23, 2006, 5:29 am
Mod_perl: can I share a database connection by putting it in thestartup-script? February 13, 2005, 4:14 pm
mysql connection failing as CGI November 21, 2006, 1:03 pm
How to set DBI connection timeout for Win32 Perl->MySQL ? October 13, 2007, 11:44 am
create connection from html form into insert MySQL data script September 8, 2004, 2:58 am
copy mysql database with perl December 22, 2004, 9:36 pm
compare two MySQL database structures April 5, 2006, 3:46 pm
Is there a wholly Perl Database equivalent to say MySQL? October 28, 2004, 11:40 am

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap