Don't ask to ask, just ask | |
PerlMonks |
Re: Sharing database handleby d_i_r_t_y (Monk) |
on Apr 21, 2002 at 03:10 UTC ( [id://160844]=note: print w/replies, xml ) | Need Help?? |
hi marcello, I have an application which forks of child processes to do all the work. At the moment, every child process creates its own database connection, does its work and closes the database connection again. This causes a lot of connections to be made to the database.
how many children are you forking?! i don't think there is a problem with many db connections as long as the work for each thread justifies the connection time overhead. on mysql, connections are cheap and fast and i wouldn't even think twice about doing it (though concurrency/locking with mysql is more or an issue...). on db2, where 1 connection costs about 750msec each (that's client/server on same machine!), you would want to have at least 750msec worth of work for each process to justify the connection overhead. that said, divide and conquer works a treat if you can break down your workload into mutually exclusive chunks. btw, have to say it's sure satisfying to see those CPUs and disks crying for mercy when you have 8 concurrent processes hammering away inserts to the db... matt
In Section
Seekers of Perl Wisdom
|
|