You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Anthony Gardner <cy...@yahoo.co.uk> on 2007/07/09 15:12:42 UTC

DBI and threaded MPM

http://perl.apache.org/docs/2.0/user/performance/mpm.html#Work_with_DataBases_under_Threaded_MPM

I'm looking into a problem we're experiencing (lots of netword connections) and I think the answer lies with Apache::DBI and the version of mod_perl we're using.

A few questions, does anyone know of the state of DBI::Pool?

If anyone is using threaded MPM and Apache::DBI, how are they dealing with sharing the the connection within the threads?

I'm looking at Thread::Sociable (preference) and threads::shared and 

I'm looking for tips and/or defacto stds used at the time of writing.
Any tips would be great while I continue playing with threads and searching for other info.

CIA

-Ants

       
---------------------------------
 Yahoo! Answers - Get better answers from someone who knows. Tryit now.

Re: DBI and threaded MPM

Posted by Perrin Harkins <pe...@elem.com>.
On 7/11/07, Anthony Gardner <cy...@yahoo.co.uk> wrote:
> A. We recently went live with a DB application and the system ground
>     to a halt. It could be due to many things, but the thing I'm looking at
>     is the fact that we had many network connections. I then found the
>     info about  Databases and threaded MPM. From what I understand,
>     DB connections created at server startup are not shared amongst
>     threads.

That's correct.  Each process or thread must have a separate connection.

Before you can fix your problem, you need to find out what the problem
is.  It sounds like you haven't done much configuration, so the most
likely problem is that you have MaxClients set really high and you are
using up all the memory on the machine and going into swap.  There's
lots of advice on the mod_perl site about how to correctly tune
MaxClients and related settings.

- Perrin

Re: DBI and threaded MPM

Posted by Foo JH <jh...@extracktor.com>.
Anthony Gardner wrote:
> Perrin, I never received your mail (actually, I hardly receive any 
> mails form this list) I have to go to the archives to see if I've 
> received any replies or to see what's been posted in general!!
You may want to check with your email admin on this. There's posting on 
this list almost daily!


Re: DBI and threaded MPM

Posted by Anthony Gardner <cy...@yahoo.co.uk>.
Perrin, I never received your mail (actually, I hardly receive any mails form this list) I have to go to the archives to see if I've received any replies or to see what's been posted in general!!

So, in answer to your questions ........


P. May I ask why you're using a threaded MPM?  Unless you're running on
   Windows, you should probably avoid it.  The threaded MPM uses a lot
   more memory than the prefork one.

A. This version of MP has just been installed and we have a dept. that deals
   with this sort of thing. It's not until we had a problem,
   that I started to look into versions of s/w etc. It's a big company
   and the admin dept. decide what to install. (I've since asked for the prefork mpm to be installed)

P. (regarding using Thread::Sociable and threads::shared)
   They won't work because DBD modules carry around XS structures which
   don't know anything about perl threads.  That's the problem DBI::Pool 
   was trying to address.

A.  After I started looking into this issue, I quickly realised that  
     these wouldn't help me.

P.  Can you explain a little more about what the problem is and why you
     think it involves Apache::DBI?

A. We recently went live with a DB application and the system ground 
    to a halt. It could be due to many things, but the thing I'm looking at   
    is the fact that we had many network connections. I then found the
    info about  Databases and threaded MPM. From what I understand, 
    DB connections created at server startup are not shared amongst
    threads.

As I see now, threaded MPM doesn't sit well with DB and really, we shouldn't be using it at all. I've made this clear to my admin dept. and we're going to install and test prefork MPM. 

Thanks for getting back to me, anyway.

-Ants

Jonathan Vanasco <jv...@2xlp.com> wrote: 
On Jul 9, 2007, at 9:12 AM, Anthony Gardner wrote:

> http://perl.apache.org/docs/2.0/user/performance/ 
> mpm.html#Work_with_DataBases_under_Threaded_MPM
>
> I'm looking into a problem we're experiencing (lots of netword  
> connections) and I think the answer lies with Apache::DBI and the  
> version of mod_perl we're using.
>
> A few questions, does anyone know of the state of DBI::Pool?
>
> If anyone is using threaded MPM and Apache::DBI, how are they  
> dealing with sharing the the connection within the threads?
>
> I'm looking at Thread::Sociable (preference) and threads::shared and
>
> I'm looking for tips and/or defacto stds used at the time of writing.
> Any tips would be great while I continue playing with threads and  
> searching for other info.

Some people here ( not including me though ) are using connect_cached  
in DBI , and bypassing Apache::DBI altogether.  you might want to try  
that.
correct me if i'm wrong.. but i believe you want to not share dbi  
connections between threads.  wouldn't you need a factory class to  
toss you a fresh connect ?
if you want to do true connection pooling, you'd be best off with  
something like sqlrelay or pgpool.  the apache::dbi/dbi cached don't  
really pool; they just override connects for established connections  
on their process and reuse them.  things like sqlrelay/pgpool will  
let you use 50 db connections for 150 server processes ( by blocking  
a lot, yes )




// Jonathan Vanasco

| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
- - - - - - - - - - - - - - - - - - -
|   CEO/Founder SyndiClick Networks
| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
- - - - - - - - - - - - - - - - - - -
|     Founder/CTO/CVO
|      FindMeOn.com - The cure for Multiple Web Personality Disorder
|      Web Identity Management and 3D Social Networking
| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
- - - - - - - - - - - - - - - - - - -
|      RoadSound.com - Tools For Bands, Stuff For Fans
|      Collaborative Online Management And Syndication Tools
| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
- - - - - - - - - - - - - - - - - - -




       
---------------------------------
 Yahoo! Mail is the world's favourite email. Don't settle for less, sign up for your freeaccount today.

Re: DBI and threaded MPM

Posted by Jonathan Vanasco <jv...@2xlp.com>.
On Jul 9, 2007, at 9:12 AM, Anthony Gardner wrote:

> http://perl.apache.org/docs/2.0/user/performance/ 
> mpm.html#Work_with_DataBases_under_Threaded_MPM
>
> I'm looking into a problem we're experiencing (lots of netword  
> connections) and I think the answer lies with Apache::DBI and the  
> version of mod_perl we're using.
>
> A few questions, does anyone know of the state of DBI::Pool?
>
> If anyone is using threaded MPM and Apache::DBI, how are they  
> dealing with sharing the the connection within the threads?
>
> I'm looking at Thread::Sociable (preference) and threads::shared and
>
> I'm looking for tips and/or defacto stds used at the time of writing.
> Any tips would be great while I continue playing with threads and  
> searching for other info.

Some people here ( not including me though ) are using connect_cached  
in DBI , and bypassing Apache::DBI altogether.  you might want to try  
that.
correct me if i'm wrong.. but i believe you want to not share dbi  
connections between threads.  wouldn't you need a factory class to  
toss you a fresh connect ?
if you want to do true connection pooling, you'd be best off with  
something like sqlrelay or pgpool.  the apache::dbi/dbi cached don't  
really pool; they just override connects for established connections  
on their process and reuse them.  things like sqlrelay/pgpool will  
let you use 50 db connections for 150 server processes ( by blocking  
a lot, yes )




// Jonathan Vanasco

| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
- - - - - - - - - - - - - - - - - - -
|   CEO/Founder SyndiClick Networks
| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
- - - - - - - - - - - - - - - - - - -
|     Founder/CTO/CVO
|      FindMeOn.com - The cure for Multiple Web Personality Disorder
|      Web Identity Management and 3D Social Networking
| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
- - - - - - - - - - - - - - - - - - -
|      RoadSound.com - Tools For Bands, Stuff For Fans
|      Collaborative Online Management And Syndication Tools
| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
- - - - - - - - - - - - - - - - - - -



Re: DBI and threaded MPM

Posted by Perrin Harkins <pe...@elem.com>.
On 7/9/07, Anthony Gardner <cy...@yahoo.co.uk> wrote:
> I'm looking into a problem we're experiencing (lots of netword connections)
> and I think the answer lies with Apache::DBI and the version of mod_perl
> we're using.

Can you explain a little more about what the problem is and why you
think it involves Apache::DBI?

> A few questions, does anyone know of the state of DBI::Pool?

There is no working version of it, but Stas did write some code which
someone else could pick up if they were interested.

> If anyone is using threaded MPM and Apache::DBI, how are they dealing with
> sharing the the connection within the threads?

No one is doing that.  It is not possible without doing some work on
every DBD module that is going to be supported.

> I'm looking at Thread::Sociable (preference) and threads::shared and

They won't work because DBD modules carry around XS structures which
don't know anything about perl threads.  That's the problem DBI::Pool
was trying to address.

May I ask why you're using a threaded MPM?  Unless you're running on
Windows, you should probably avoid it.  The threaded MPM uses a lot
more memory than the prefork one.

- Perrin