You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Alex Bligh <al...@alex.org.uk> on 2012/03/09 15:04:19 UTC

[users@httpd] Restricting mod-dbd by location

I have a busy websebserver with a configuration like this:

<VirtualHost 192.200.1.1:443>
        SSLEngine on
	DocumentRoot /opt/busy

        DBDriver pgsql
        DBDParams "host=192.200.2.2 dbname=foo user=foo password=foo"
        DBDMin  4
        DBDKeep 8
        DBDMax  20
        DBDExptime 300

	<Location /idle>
             SetHandler websocket-handler
             ....
        </Location>

</VirtualHost>


The DBD driver is only needed by the websocket-handler within /idle. The
remainder of the virtual host does not need it.

My problem is that EVERY connection to the VirtualHost appears to
open a DBDDriver connection (I am running non-threaded due to various
legacy nonsense). That causes a huge strain on the database. I only
want a connection to be acquired if the connection is made to /idle.

To be clear, I can avoid making ANY request to /idle, and my database
still gets hammered.

I appear not be able to put the DBD stuff within a <Location> block.

I cannot redirect the /idle bit to another VirtualHost, as I need to
use IP based SSL with the same endpoint.

Any ideas on how I could restrict DBD connections to be only acquired
when connecting to the Location?

-- 
Alex Bligh

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] Restricting mod-dbd by location

Posted by Alex Bligh <al...@alex.org.uk>.
Nick,

--On 9 March 2012 19:20:17 +0000 Nick Kew <ni...@webthing.com> wrote:

>> if I have (say) 100 mpm-prefork workers, and 0.001%
>> of my queries are to the <Location> concerned (this ratio is
>> approximately correct numerically), I don't really want 100 database
>> connections constantly open, lasting for the life of the mpm-prefork
>> worker.
>
> Then you want the classic-CGI-style setup.  DBD will give you that
> with min=0, max=1, and no keepalive on the connections.

Thanks.

By 'no keepalive' do you mean 'DBDPersist off'?

-- 
Alex Bligh

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] Restricting mod-dbd by location

Posted by Nick Kew <ni...@webthing.com>.
On Fri, 09 Mar 2012 16:37:44 +0000
Alex Bligh <al...@alex.org.uk> wrote:

> However, I /think/ it means that there is one connection per
> worker in a non-threaded environment still?

In a non-threaded environment, your choices are the two classic/
ancient models: original CGI (one connection per hit) and original
LAMP (one persistent connection per process).

> if I have (say) 100 mpm-prefork workers, and 0.001%
> of my queries are to the <Location> concerned (this ratio is approximately
> correct numerically), I don't really want 100 database connections
> constantly open, lasting for the life of the mpm-prefork worker.

Then you want the classic-CGI-style setup.  DBD will give you that
with min=0, max=1, and no keepalive on the connections.

Most people don't want that setup, because opening and closing
database connections is too much overhead.  But with prefork and
your numbers it makes sense.  Though a threaded MPM and a small
number of persistent connections would be ideal!

> Or can it pool connections between mpm-prefork workers?

Nope.

-- 
Nick Kew

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] Restricting mod-dbd by location

Posted by Alex Bligh <al...@alex.org.uk>.
Nick,

--On 9 March 2012 15:05:10 +0000 Nick Kew <ni...@webthing.com> wrote:

>>    (I am running non-threaded due to various
>> legacy nonsense).
>
> If you're running non-threaded then those DBD settings make
> no sense: you need DBDMax of 1 and DBDMin of 0 or 1.

That's fine, I suppose, as far as it goes, and thank you
for pointing it out.

However, I /think/ it means that there is one connection per
worker in a non-threaded environment still?

if I have (say) 100 mpm-prefork workers, and 0.001%
of my queries are to the <Location> concerned (this ratio is approximately
correct numerically), I don't really want 100 database connections
constantly open, lasting for the life of the mpm-prefork worker.

Or can it pool connections between mpm-prefork workers?

-- 
Alex Bligh

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] Restricting mod-dbd by location

Posted by Nick Kew <ni...@webthing.com>.
On Fri, 09 Mar 2012 14:04:19 +0000
Alex Bligh <al...@alex.org.uk> wrote:

>    (I am running non-threaded due to various
> legacy nonsense).

If you're running non-threaded then those DBD settings make
no sense: you need DBDMax of 1 and DBDMin of 0 or 1.

I suppose it's a buglet that mod_dbd only knows whether APR is
threaded and lets you do that when you have threaded APR and
an unthreaded MPM.

-- 
Nick Kew

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org