You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modules-dev@httpd.apache.org by John Zhang <jo...@yahoo.com> on 2007/10/31 21:41:59 UTC

Where is the right place to setup a connection pool?

I am writing a module talking to a remote server that
handles the real work.  I need to build/keep a pool of
connections for reuse almong the different Apache
worker threads.  Should I build that in the
ap_hook_post_config or ap_hook_child_init function?

When apache creates multiple processes, will each
process have its own copy of the connection pool
automatically (taken care by apache) or I will have to
do more work?

Thanks in advance for any help.

John

Re: Where is the right place to setup a connection pool?

Posted by Nick Kew <ni...@webthing.com>.
On Wed, 31 Oct 2007 13:41:59 -0700 (PDT)
John Zhang <jo...@yahoo.com> wrote:

> I am writing a module talking to a remote server that
> handles the real work.  I need to build/keep a pool of
> connections for reuse almong the different Apache
> worker threads.

Further to my previous reply ...

What you wrote sounds broadly proxy-like.  Maybe all you
need to write is a protocol provider module for mod_proxy,
and leave mod_proxy to take care of connection pooling?
mod_proxy already supports applications protocols
(mod_proxy_ajp, mod_proxy_fcgi) in addition to the more
traditional proxy protocols (mod_proxy_http, mod_proxy_ftp).

-- 
Nick Kew

Application Development with Apache - the Apache Modules Book
http://www.apachetutor.org/

Re: Where is the right place to setup a connection pool?

Posted by John Zhang <jo...@yahoo.com>.
Thanks Nick!
    I am actually reading your book.  Will your
example on Thread Safety (4.5.1) work (setup the pool
in init_child hook with thread mutex)?  I do not need
a global mutex, right?  I have not read the late
chapters yet.

With Regards,
John

--- Nick Kew <ni...@webthing.com> wrote:

> On Wed, 31 Oct 2007 13:41:59 -0700 (PDT)
> John Zhang <jo...@yahoo.com> wrote:
> 
> > Thanks in advance for any help.
> 
> Use an apr_reslist to manage the pool.
> See mod_dbd for an example.
> 
> -- 
> Nick Kew
> 
> Application Development with Apache - the Apache
> Modules Book
> http://www.apachetutor.org/
> 


Re: Where is the right place to setup a connection pool?

Posted by Nick Kew <ni...@webthing.com>.
On Wed, 31 Oct 2007 13:41:59 -0700 (PDT)
John Zhang <jo...@yahoo.com> wrote:

> Thanks in advance for any help.

Use an apr_reslist to manage the pool.
See mod_dbd for an example.

-- 
Nick Kew

Application Development with Apache - the Apache Modules Book
http://www.apachetutor.org/