Is there a way to get mod_perl/Apache::DBI to hold (multiple) connections around so that users can exec the same CGI concurrently without having to wait?
Apache::DBI does hold the database connections open. One connection for each process. But only under mod_perl, not CGI (don't confuse the two, Apache::Registry lets your CGI scripts run under mod_perl, but then it's not CGI anymore). That's not connection pooling though. Each apache process will hold a database connection open, which means if you allow 1000 simultaneous processes for 1000 people hitting your site at once, there are 1000 connections. (update: connection "pooling" would be something more like having those 1000 processes share a pool of 100 connections, and having each processes grabbing an available connection as needed, then releasing it back to the pool when done).
True connection pooling is possible with Sybase (there's a module on CPAN), but most databases don't support that. Besides, Sybase only allows one active statement handle per connection, so it tends to need more than one connection more than other databases (update: that's been changed, it now transparently opens more connections for more statement handles, but now I'm probably getting OT).
Update: Just noticed that it says Apache 2.x, which I vaguely think I remember supports connection pooling, but I don't know how...
and more thoughts on the subject (a post in the thread in the first link of this google currently proposes that connection pooling is actually rarely needed, and that people only think they need it because MS has it).
| [reply] |
I think that cleared things up for me...Thanks :)
I am running my scripts under mod_perl using: PerlResponseHandler ModPerl::PerlRun (just to see how they'd work, will probably use Registry later).
Just wanted to verify something you wrote, though:
Each apache process will hold a database connection open...
You are saying that for each Apache process that is spawned, it gets its own database handle that it holds?
| [reply] |
Each Perl interpreter keeps a connection open. With the pre-fork MPM (or mod_perl 1.x), that means one per process.
There is a working prototype right now for true pooling of db connections between threads, so hopefully that will be available soon. However, this is really only helpful for applications that do a lot of non-database work and ones where each user has a different database login.
| [reply] |
Just wanted to say... lucky you. I have mod_perl 1.99_05-3 and apache 2.0.40 installed, and I can't seem to get Apache::DBI to work. It needs Apache2.pm, and some otehr things, and none of it is working :(
If the above content is missing any vital points or you feel that any of the information is misleading, incorrect or irrelevant, please feel free to downvote the post. At the same time, please reply to this node or /msg me to inform me as to what is wrong with the post, so that I may update the node to the best of my ability.
| [reply] |
| [reply] |
You may also want to check out SQLrelay. I've messed with it a bit in a testing environment, and it seems to do exactly what you are looking for. The documentation leaves a little to be desired, and some of the other engineers I work with seem a little worried about the stability of the group maintaining the code, but it may be worth a look:
sqlrelay.sourceforge.net
| [reply] |