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



On 2008-03-31 03:45, Andrew DeFaria <Andrew@xxxxxxxxxxx> wrote:
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

.



Relevant Pages

  • Re: Confusion about database updates
    ... all connecting to the same database server. ... >> The problem occurs when connection to the database server is lost. ... Let the MySQL server do that when your client ...
    (comp.lang.java.databases)
  • [PATCH 0/5] [RFC] AF_RXRPC socket family implementation [try #3]
    ... These patches together supply secure client-side RxRPC connectivity as a Linux ... kernel socket family. ... presentation side is left to the client. ... Each connection goes to a particular "service". ...
    (Linux-Kernel)
  • Re: ORA-12535: TNS:operation timed out errors for over a year now...
    ... 'attach database'. ... At a middle tier - a server sitting between the client and the Oracle ... There is a VPN connection or some type of WAN link between the server ...
    (comp.databases.oracle.server)
  • Re: Access 2003 to SQL Server 2000 over a VPN
    ... The client runs a VP from Philly to NYC. ... Would you consider using an ADP talking across an fast broadbank link to ... local database, but ideally we would like to centralise. ... the front end over a VPN connection. ...
    (microsoft.public.access.adp.sqlserver)
  • Help ! -> Distributed BL and Database Access
    ... I have one server located in a remote part of the country ... method the data within the object will be comitted to the database. ... reference to the database connection and then send it to the client (by ... value - to move the work off onto the client). ...
    (microsoft.public.dotnet.framework.remoting)