Mailing List Archive

Modifying @INC on a Per-VirtualHost
Hi list,

I have a question regarding tuning @INC at VirtualHost level, with prefork MPM.

In the doc :
https://perl.apache.org/docs/2.0/user/config/config.html#Modifying_C__INC__on_a_Per_VirtualHost
is written :
"under prefork your procs will be huge, because
you will build a pool of interpreters in each process"

Let's then imagine the following configuration :

Several VH (let's say 10) with the same PerlSwitches configuration :
<VirtualHost ...>
PerlSwitches -I/home/production/lib/perl
</VirtualHost>

And one VH with another PerlSwitches configuration :
<VirtualHost ...>
PerlSwitches -I/home/development/lib/perl
</VirtualHost>

My question is then about the "pool of interpreters".
I understand that several interpreters will be launched because they
require different @INC configurations.
But in my example, will I have 2 (2 different PerlSwitches configurations)
or 11 (11 different VH using PerlSwitches) interpreters launched ?

The difference is rather important.

Thank you very much !

Best regards,

Ben
Re: Modifying @INC on a Per-VirtualHost [ In reply to ]
> On 19 Aug 2017, at 22:40, Ben RUBSON <ben.rubson@gmail.com> wrote:
>
> Hi list,
>
> I have a question regarding tuning @INC at VirtualHost level, with prefork MPM.
> (...)
> will I have 2 (2 different PerlSwitches configurations)
> or 11 (11 different VH using PerlSwitches) interpreters launched ?

Well, reading at Parent (which is needed), gave me the answer :
https://perl.apache.org/docs/2.0/user/config/config.html#C_Parent_

I will have 11 interpreters.

So a better configuration would be :

PerlSwitches -T -I/home/production/lib/perl
<VirtualHost prod1>
...
</VirtualHost>
<VirtualHost prod2>
...
</VirtualHost>
<VirtualHost prodn>
...
</VirtualHost>

<VirtualHost dev>
PerlOptions +Parent
PerlSwitches -I/home/development/lib/perl
</VirtualHost>

However, here is what I have reaching VH dev :
[warn] -T switch is ignored, enable with 'PerlSwitches -T' in httpd.conf
And according to ${^TAINT}, taint is no more enabled in VH dev.
Any workaround ?

Many thanks again !

Ben
Re: Modifying @INC on a Per-VirtualHost [ In reply to ]
On 19.08.2017 23:29, Ben RUBSON wrote:
>> On 19 Aug 2017, at 22:40, Ben RUBSON <ben.rubson@gmail.com> wrote:
>>
>> Hi list,
>>
>> I have a question regarding tuning @INC at VirtualHost level, with prefork MPM.
>> (...)
>> will I have 2 (2 different PerlSwitches configurations)
>> or 11 (11 different VH using PerlSwitches) interpreters launched ?
>
> Well, reading at Parent (which is needed), gave me the answer :
> https://perl.apache.org/docs/2.0/user/config/config.html#C_Parent_
>
> I will have 11 interpreters.
>
> So a better configuration would be :
>
> PerlSwitches -T -I/home/production/lib/perl
> <VirtualHost prod1>
> ...
> </VirtualHost>
> <VirtualHost prod2>
> ...
> </VirtualHost>
> <VirtualHost prodn>
> ...
> </VirtualHost>
>
> <VirtualHost dev>
> PerlOptions +Parent
> PerlSwitches -I/home/development/lib/perl
> </VirtualHost>
>
> However, here is what I have reaching VH dev :
> [warn] -T switch is ignored, enable with 'PerlSwitches -T' in httpd.conf
> And according to ${^TAINT}, taint is no more enabled in VH dev.
> Any workaround ?
>

Maybe another possible solution for what I think you are trying to achieve.
...
<VirtualHost dev>
ProxyPass "/" "http://dev.sameserver.local:8000/"
ProxyPassReverse "/" "http://dev.sameserver.local:8000/"
</VirtualHost>

Add this to the local /etc/hosts file:
127.0.0.1 dev.sameserver.local

and run *another Apache instance*, with another perl/mod_perl, on port 8000,
with a
<VirtualHost *:8000>
ServerName dev.sameserver.local
...
</VirtualHost>
and watever @INC you want.

For the clients, it will look just the same (they continue to access
"http://dev.company.com:80/*"). There will be a (very small) overhead for the proxying,
but which affects only your dev people.
You can (carefully) share a DocumentRoot and whatever with the main instance, or not.
And it will certainly use less memory than 11 perl interpreters per Apache child.
Re: Modifying @INC on a Per-VirtualHost [ In reply to ]
> On 20 Aug 2017, at 11:28, Andr? Warnier (tomcat) <aw@ice-sa.com> wrote:
>
> On 19.08.2017 23:29, Ben RUBSON wrote:
>>> On 19 Aug 2017, at 22:40, Ben RUBSON <ben.rubson@gmail.com> wrote:
>>>
>>> Hi list,
>>>
>>> I have a question regarding tuning @INC at VirtualHost level, with prefork MPM.
>>> (...)
>>> will I have 2 (2 different PerlSwitches configurations)
>>> or 11 (11 different VH using PerlSwitches) interpreters launched ?
>>
>> Well, reading at Parent (which is needed), gave me the answer :
>> https://perl.apache.org/docs/2.0/user/config/config.html#C_Parent_
>>
>> I will have 11 interpreters.
>>
>> So a better configuration would be :
>>
>> PerlSwitches -T -I/home/production/lib/perl
>> <VirtualHost prod1>
>> ...
>> </VirtualHost>
>> <VirtualHost prod2>
>> ...
>> </VirtualHost>
>> <VirtualHost prodn>
>> ...
>> </VirtualHost>
>>
>> <VirtualHost dev>
>> PerlOptions +Parent
>> PerlSwitches -I/home/development/lib/perl
>> </VirtualHost>
>>
>> However, here is what I have reaching VH dev :
>> [warn] -T switch is ignored, enable with 'PerlSwitches -T' in httpd.conf
>> And according to ${^TAINT}, taint is no more enabled in VH dev.
>> Any workaround ?
>>
>
> Maybe another possible solution for what I think you are trying to achieve.

Thank you very much for your answer André, hum, Andr? !

> ...
> <VirtualHost dev>
> ProxyPass "/" "http://dev.sameserver.local:8000/"
> ProxyPassReverse "/" "http://dev.sameserver.local:8000/"
> </VirtualHost>
>
> Add this to the local /etc/hosts file:
> 127.0.0.1 dev.sameserver.local
>
> and run *another Apache instance*, with another perl/mod_perl, on port 8000,
> with a
> <VirtualHost *:8000>
> ServerName dev.sameserver.local
> ...
> </VirtualHost>
> and watever @INC you want.

Yes why not, this is a nice solution !

> For the clients, it will look just the same (they continue to access "http://dev.company.com:80/*"). There will be a (very small) overhead for the proxying, but which affects only your dev people.
> You can (carefully) share a DocumentRoot and whatever with the main instance, or not.
> And it will certainly use less memory than 11 perl interpreters per Apache child.

With the solution in my second mail (you quoted above), I just only have 2 interpreter pools : the one for all prod VH, and the one for the dev VH.
So seems to be OK in terms of interpreters consumption.
I managed to get ride of the taint warning, and to get taint enabled in the dev VH adding this to the dev VH config :
PerlTaintCheck on
Seems however to be a mod_perl 1.0 config option, so I don't know if it is a best practice or not to still use it...
I don't know if we should prefer in any way "PerlSwitches -T", or if "PerlTaintCheck on" is OK / has exactly the same effect / has no overhead etc...

Thank you again !

Ben
Re: Modifying @INC on a Per-VirtualHost [ In reply to ]
> On 20 Aug 2017, at 11:45, Ben RUBSON <ben.rubson@gmail.com> wrote:
>
> I managed to get ride of (...)

to get rid, you will have corrected :)