You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Joshua Johnson <jo...@gmail.com> on 2010/05/27 21:36:01 UTC

mod_perl and mass virtual hosting

Hello all,

I have a question on using mod_perl to configure apache for many virtual
hosts. My problem is the high load on the apache server. I decided to go
with mod_perl to configure apache and here are the reasons (if I should be
doing this a different way, please say so. I'm open to suggestions).:

The company I work at has ~13,000 customer domains. There is a database
where these domains are configured. Some of them are "standard" packages and
simply have a document root where customers upload pages. Some of the
domains make proxy requests to another site. And still others make a proxied
rewrite from "/" to "some random url that is stored in the db". Some
redirect to another url. There are about 20 other such configurations.

I used mod_perl to load all of this up at startup and it worked beautifully.
I originally thought that I would be able to dynamically setup VirtuaHost
sections as requests came in for domains (maybe they were freshly added to
the db or the record updated). But I found you can't really do that so I
have to restart for changes to take effect. Either way, I'm very happy with
how easy and clean mod_perl has made all of this.

But the load on apache runs anywhere from 0.50 to 3.00 on a dual cpu server.
Response doesn't seem slow (except for right after an apache restart) but
I'm worried that I'm doing something fundamentally wrong. There is a
significant amount of proxying going on so I set "ProxyReceiveBufferSize
16384" but that doesn't seem to have changed too much. Could mod_perl be the
cause of the load or would it be the end apache config? Are there any
initial thoughts anyone has? Has anyone run into something similar? Should I
be going about this a different way?

Related: and would it be possible to add config on-the-fly? $r->add_config()
Won't let you add VirtualHosts because it operates as though in a <Location>
directive.

I guess I'm just looking for thoughts in general. I've been tinkering with
this for about 2 weeks now.

Thanks,
Josh J

Re: mod_perl and mass virtual hosting

Posted by Torsten Förtsch <to...@gmx.net>.
On Thursday 27 May 2010 21:36:01 Joshua Johnson wrote:
> Related: and would it be possible to add config on-the-fly?
>  $r->add_config() Won't let you add VirtualHosts because it operates as
>  though in a <Location> directive.
> 
I do most of the request config with $r->add_config(). The httpd.conf contains 
2 Vhosts per IP, 1 plain, 1 SSL. At runtime the Host HTTP header then decides 
what to do. This resembles very much name based vhosts without actually having 
vhosts. On the positive side one can add "vhosts" without restarting apache, 
on the negative there is only one error_log/access_log. The access_log can be 
splitted afterwards if the Host header is logged. I actually log to named 
pipes. The web server runs inside a chroot, the log reader outside.

Torsten Förtsch

-- 
Need professional modperl support? Hire me! (http://foertsch.name)

Like fantasy? http://kabatinte.net

Re: mod_perl and mass virtual hosting

Posted by Joshua Johnson <jo...@gmail.com>.
Fred,

Yes, mod_perl and mod_proxy are on the same httpd.

Perrin,

For clarification, I'm using <Perl> sections to create the config from info
stored in various databases but mod_rewrite and mod_proxy are doing the real
work. There are no Perl Handlers.

I think I will try writing out the config and see if that changes the load
at all and then start going into your suggestions, Fred, and try going
through another front end proxy. Don't want to introduce too many variables
at the same time.

Thanks for the suggestions, guys.
-Josh J

On Thu, May 27, 2010 at 4:02 PM, Perrin Harkins <pe...@elem.com> wrote:

> I second what Fred said.  Also, you might consider just generating a
> config file for apache with perl and not running mod_perl in the
> server.  I try to avoid using mod_perl for things that mod_rewrite and
> mod_proxy can handle.
>
> - Perrin
>
> On Thu, May 27, 2010 at 3:39 PM, Fred Moyer <fr...@redhotpenguin.com>
> wrote:
> > It sounds like you are using mod_perl and mod_proxy on the same main
> > httpd, is that right?
> >
> > If so, consider running another front end proxy such as apache with
> > the event_mpm, perlbal, ha_proxy, or nginx.  Without having more
> > details (Devel::NYT::Prof may provide some), my guess is that you are
> > blocking on child httpds in mod_proxy.
> >
> > On Thu, May 27, 2010 at 12:36 PM, Joshua Johnson
> > <jo...@gmail.com> wrote:
> >> Hello all,
> >>
> >> I have a question on using mod_perl to configure apache for many virtual
> >> hosts. My problem is the high load on the apache server. I decided to go
> >> with mod_perl to configure apache and here are the reasons (if I should
> be
> >> doing this a different way, please say so. I'm open to suggestions).:
> >>
> >> The company I work at has ~13,000 customer domains. There is a database
> >> where these domains are configured. Some of them are "standard" packages
> and
> >> simply have a document root where customers upload pages. Some of the
> >> domains make proxy requests to another site. And still others make a
> proxied
> >> rewrite from "/" to "some random url that is stored in the db". Some
> >> redirect to another url. There are about 20 other such configurations.
> >>
> >> I used mod_perl to load all of this up at startup and it worked
> beautifully.
> >> I originally thought that I would be able to dynamically setup
> VirtuaHost
> >> sections as requests came in for domains (maybe they were freshly added
> to
> >> the db or the record updated). But I found you can't really do that so I
> >> have to restart for changes to take effect. Either way, I'm very happy
> with
> >> how easy and clean mod_perl has made all of this.
> >>
> >> But the load on apache runs anywhere from 0.50 to 3.00 on a dual cpu
> server.
> >> Response doesn't seem slow (except for right after an apache restart)
> but
> >> I'm worried that I'm doing something fundamentally wrong. There is a
> >> significant amount of proxying going on so I set "ProxyReceiveBufferSize
> >> 16384" but that doesn't seem to have changed too much. Could mod_perl be
> the
> >> cause of the load or would it be the end apache config? Are there any
> >> initial thoughts anyone has? Has anyone run into something similar?
> Should I
> >> be going about this a different way?
> >>
> >> Related: and would it be possible to add config on-the-fly?
> $r->add_config()
> >> Won't let you add VirtualHosts because it operates as though in a
> <Location>
> >> directive.
> >>
> >> I guess I'm just looking for thoughts in general. I've been tinkering
> with
> >> this for about 2 weeks now.
> >>
> >> Thanks,
> >> Josh J
> >>
> >>
> >
>

Re: mod_perl and mass virtual hosting

Posted by Perrin Harkins <pe...@elem.com>.
I second what Fred said.  Also, you might consider just generating a
config file for apache with perl and not running mod_perl in the
server.  I try to avoid using mod_perl for things that mod_rewrite and
mod_proxy can handle.

- Perrin

On Thu, May 27, 2010 at 3:39 PM, Fred Moyer <fr...@redhotpenguin.com> wrote:
> It sounds like you are using mod_perl and mod_proxy on the same main
> httpd, is that right?
>
> If so, consider running another front end proxy such as apache with
> the event_mpm, perlbal, ha_proxy, or nginx.  Without having more
> details (Devel::NYT::Prof may provide some), my guess is that you are
> blocking on child httpds in mod_proxy.
>
> On Thu, May 27, 2010 at 12:36 PM, Joshua Johnson
> <jo...@gmail.com> wrote:
>> Hello all,
>>
>> I have a question on using mod_perl to configure apache for many virtual
>> hosts. My problem is the high load on the apache server. I decided to go
>> with mod_perl to configure apache and here are the reasons (if I should be
>> doing this a different way, please say so. I'm open to suggestions).:
>>
>> The company I work at has ~13,000 customer domains. There is a database
>> where these domains are configured. Some of them are "standard" packages and
>> simply have a document root where customers upload pages. Some of the
>> domains make proxy requests to another site. And still others make a proxied
>> rewrite from "/" to "some random url that is stored in the db". Some
>> redirect to another url. There are about 20 other such configurations.
>>
>> I used mod_perl to load all of this up at startup and it worked beautifully.
>> I originally thought that I would be able to dynamically setup VirtuaHost
>> sections as requests came in for domains (maybe they were freshly added to
>> the db or the record updated). But I found you can't really do that so I
>> have to restart for changes to take effect. Either way, I'm very happy with
>> how easy and clean mod_perl has made all of this.
>>
>> But the load on apache runs anywhere from 0.50 to 3.00 on a dual cpu server.
>> Response doesn't seem slow (except for right after an apache restart) but
>> I'm worried that I'm doing something fundamentally wrong. There is a
>> significant amount of proxying going on so I set "ProxyReceiveBufferSize
>> 16384" but that doesn't seem to have changed too much. Could mod_perl be the
>> cause of the load or would it be the end apache config? Are there any
>> initial thoughts anyone has? Has anyone run into something similar? Should I
>> be going about this a different way?
>>
>> Related: and would it be possible to add config on-the-fly? $r->add_config()
>> Won't let you add VirtualHosts because it operates as though in a <Location>
>> directive.
>>
>> I guess I'm just looking for thoughts in general. I've been tinkering with
>> this for about 2 weeks now.
>>
>> Thanks,
>> Josh J
>>
>>
>

Re: mod_perl and mass virtual hosting

Posted by Fred Moyer <fr...@redhotpenguin.com>.
It sounds like you are using mod_perl and mod_proxy on the same main
httpd, is that right?

If so, consider running another front end proxy such as apache with
the event_mpm, perlbal, ha_proxy, or nginx.  Without having more
details (Devel::NYT::Prof may provide some), my guess is that you are
blocking on child httpds in mod_proxy.

On Thu, May 27, 2010 at 12:36 PM, Joshua Johnson
<jo...@gmail.com> wrote:
> Hello all,
>
> I have a question on using mod_perl to configure apache for many virtual
> hosts. My problem is the high load on the apache server. I decided to go
> with mod_perl to configure apache and here are the reasons (if I should be
> doing this a different way, please say so. I'm open to suggestions).:
>
> The company I work at has ~13,000 customer domains. There is a database
> where these domains are configured. Some of them are "standard" packages and
> simply have a document root where customers upload pages. Some of the
> domains make proxy requests to another site. And still others make a proxied
> rewrite from "/" to "some random url that is stored in the db". Some
> redirect to another url. There are about 20 other such configurations.
>
> I used mod_perl to load all of this up at startup and it worked beautifully.
> I originally thought that I would be able to dynamically setup VirtuaHost
> sections as requests came in for domains (maybe they were freshly added to
> the db or the record updated). But I found you can't really do that so I
> have to restart for changes to take effect. Either way, I'm very happy with
> how easy and clean mod_perl has made all of this.
>
> But the load on apache runs anywhere from 0.50 to 3.00 on a dual cpu server.
> Response doesn't seem slow (except for right after an apache restart) but
> I'm worried that I'm doing something fundamentally wrong. There is a
> significant amount of proxying going on so I set "ProxyReceiveBufferSize
> 16384" but that doesn't seem to have changed too much. Could mod_perl be the
> cause of the load or would it be the end apache config? Are there any
> initial thoughts anyone has? Has anyone run into something similar? Should I
> be going about this a different way?
>
> Related: and would it be possible to add config on-the-fly? $r->add_config()
> Won't let you add VirtualHosts because it operates as though in a <Location>
> directive.
>
> I guess I'm just looking for thoughts in general. I've been tinkering with
> this for about 2 weeks now.
>
> Thanks,
> Josh J
>
>