in reply to Sharing a database handle over multiple processes
A DBI database handle does survive across fork().
But the problem here is, when a child exits, the database handle gets disconnected, and since the same database connection is shared among the other children, this will affect them as well.
But the problem here is, when a child exits, the database handle gets disconnected, and since the same database connection is shared among the other children, this will affect them as well.
If the overhead of connect() is really the bottleneck of your system,
then I'd suggest you to follow the apache/mod_perl model:
a child doesn't exit immediately after serving a client, but doing an accept() loop instead
to serve more subsequent requests until a certain maximum number reached.
Your program still
creates a new $dbh for each forked child, but this $dbh is reused several times
within the child before exits, not just once. This way you reduce the number
of connect().
Update: Added a suggestion.
|
---|
In Section
Seekers of Perl Wisdom