Hello, as I am offering a free psgi / plack perl hosting at http://1.ai and I am currently using Plack::Handler::Apache2 I was wondering if there is any way to have the handler to behave a bit like passenger for ruby. My understanding is that with the current setup the perl app is reloaded at each request and some developers rightly say that this is pretty ugly ;)
I know that I could reverse proxy and use starman but I was wondering if there is a better way a bit like passenger does for ruby. Of course I know that plack is very different so it might not be possible. If this is the case would the setup I offer with Plack::Handler::Apache2 be sufficient to most (for testing, prototyping etc) ?
Another thing is that I need to declare in the vhost the full path to the app. Is there any way to specify just a directory (again in ruby this is how passenger works and the name of the app is in the config.ru file).
If there is any way to improve the apache handler and you need some sponsorship for that just let me know :)
In alternative I could rework the system to behave a bit like other services like dotcloud or heroku hence using starman in reverse proxy...
> Hello,
> as I am offering a free psgi / plack perl hosting at http://1.ai and I am currently using Plack::Handler::Apache2 I was wondering if there is > any way to have the handler to behave a bit like passenger for ruby. My understanding is that with the current setup the perl app is reloaded at each request
> and some developers rightly say that this is pretty ugly ;)
No, Plack::Handler::Apache2 compiles the psgi app on the first request and does NOT reload at each request.
> I know that I could reverse proxy and use starman but I was wondering if there is a better way a bit like passenger does for ruby. Of course I know that plack is very > different so it might not be possible. If this is the case would the setup I offer with Plack::Handler::Apache2 be sufficient to most (for testing, prototyping etc) ?
> Another thing is that I need to declare in the vhost the full path to the app. Is there any way to specify just a directory (again in ruby this is how passenger works and the name of the app is in the config.ru file).
AFAIK there's no implementation like Passenger- style dynamic workers, but uWSGI might be worth looking into if you want to host multiple apps inside the web servers.
However it is dangerous to provide access to the same perl interpreter to multiple tenants anyway, for obvious security reasons with code and memory sharing.
It would be better to run isolated worker processes (with Starman or FastCGI), or even better, provide the isolated virtual environment with LXC (like Heroku, dotcloud and Stackato).
> If there is any way to improve the apache handler and you need some sponsorship for that just let me know :)
> In alternative I could rework the system to behave a bit like other services like dotcloud or heroku hence using starman in reverse proxy…
>> Hello,
>> as I am offering a free psgi / plack perl hosting at http://1.ai and I
>> am currently using Plack::Handler::Apache2 I was wondering if there is
>> any way to have the handler to behave a bit like passenger for ruby. My
>> understanding is that with the current setup the perl app is reloaded at
>> each request
>> and some developers rightly say that this is pretty ugly ;)
> No, Plack::Handler::Apache2 compiles the psgi app on the first request and
> does NOT reload at each request.
>> I know that I could reverse proxy and use starman but I was wondering if
>> there is a better way a bit like passenger does for ruby. Of course I
>> know that plack is very
>> different so it might not be possible. If this is the case would the
>> setup I offer with Plack::Handler::Apache2 be sufficient to most (for
>> testing, prototyping etc) ?
>> Another thing is that I need to declare in the vhost the full path to
>> the app. Is there any way to specify just a directory (again in ruby
>> this is how passenger works and the name of the app is in the config.ru
>> file).
> AFAIK there's no implementation like Passenger- style dynamic workers, but
> uWSGI might be worth looking into if you want to host multiple apps inside
> the web servers.
uWSGI has solutions for practically all of the hosting-related scenarios
(you can see it as passenger with steroids without hiding the internals to
the sysadmin), but does not play well with 'static' webservers like apache
where config logic is not too smart/dynamic.
When users need to maintain apache, they tend to combine it with uwsgi's
fastrouter to give a 'brain' to apache, but its overhead could be
'relevant' on apache+massive hosting.
+1 for isolating users in jail/containers/lxc, i know it would means
rewriting the whole infrastructure, but if you want to give quality to
customers, security/isolation should be the first point on your list.
On Friday, September 21, 2012 1:24:24 AM UTC+2, Tatsuhiko Miyagawa wrote:
> No, Plack::Handler::Apache2 compiles the psgi app on the first request and > does NOT reload at each request.
This is great news ! :) So in terms of performance what is the difference between running an app under plack::handler::apache2 vs. starman with e.g. 10 workers? e.g. on http://dancer.1.ai I am running starman 10 workers and on http://elephant.1.ai/perl Plack::Handler and while it is difficult to benchmark such a simple script it looks like Plack::Handler is at least as fast. Another question: changes to the plack::handler server script do not need a restart (hence some users claimed it was reloading at each request) is there something I am missing ?
> It would be better to run isolated worker processes (with Starman or > FastCGI), or even better, provide the isolated virtual environment with LXC > (like Heroku, dotcloud and Stackato).
> I agree. I tried something different too: running each app in a bsd jail
and reverse proxing it via nginx. This seems (security-wise) a good solution too ?
> If there is any way to improve the apache handler and you need some > sponsorship for that just let me know :)
> In alternative I could rework the system to behave a bit like other > services like dotcloud or heroku hence using starman in reverse proxy…
> dotcloud uses uwsgi behind nginx.
I would certainly try it .
On a totally unrelated note you might consider adding a donation/sponsorship link to your page? I would be happy to show some support to your amazing work!
> uWSGI has solutions for practically all of the hosting-related scenarios > (you can see it as passenger with steroids without hiding the internals to > the sysadmin), but does not play well with 'static' webservers like apache > where config logic is not too smart/dynamic.
I understand. The benefit of apache for now was that it runs each script as the unprivileged user and I didn't find the same option with nginx. Obviously this is not needed if the app is isolated in a container.
> When users need to maintain apache, they tend to combine it with uwsgi's > fastrouter to give a 'brain' to apache, but its overhead could be > 'relevant' on apache+massive hosting.
> +1 for isolating users in jail/containers/lxc, i know it would means > rewriting the whole infrastructure, but if you want to give quality to > customers, security/isolation should be the first point on your list.
> Thank you I will certainly change the system in this direction. The only
problem I faced is on the ruby in a bsd jail + thin + nginx simple scripts worked fine but more complex ones did not. I did not have the same problem with starman. More testing is needed perhaps !
On Sun, Sep 23, 2012 at 1:12 AM, gurugeek <1...@1.ai> wrote:
>> No, Plack::Handler::Apache2 compiles the psgi app on the first request and
>> does NOT reload at each request.
> This is great news ! :) So in terms of performance what is the difference
> between running an app under plack::handler::apache2 vs. starman with e.g.
> 10 workers?
> e.g. on http://dancer.1.ai I am running starman 10 workers and on
> http://elephant.1.ai/perl Plack::Handler and while it is difficult to
> benchmark such a simple script it looks like Plack::Handler is at least as
> fast.
I don't understand why it is difficult to benchmark - use apachebench
or jmeter etc. to benchmark your web app. I can't generalize the
performance but i wouldn't also be surprised if Apache2 handler is as
fast.
> Another question: changes to the plack::handler server script do not
> need a restart (hence some users claimed it was reloading at each request)
> is there something I am missing ?
I don't understand what you mean by "Plack::Handler server script",
but Plack::Handler::Apache2 definitely compiles the app only once. If
you have multiple Apache children workers it will compile once for
each children, so it might look like it's reloading if you hit a
worker with no compiled result. To avoid that you can preload the apps
in the httpd.conf. These are documented in the POD docs.
> On a totally unrelated note you might consider adding a donation/sponsorship
> link to your page? I would be happy to show some support to your amazing
> work!
You can buy and promote the book http://handbook.plackperl.org/ to
give me a little bit of money, but otherwise I don't take donation nor
sponsorship for developments because money isn't my motivation and i
don't need a financial support. I would gladly take beer offers at
conferences party though :)
> I don't understand what you mean by "Plack::Handler server script", > but Plack::Handler::Apache2 definitely compiles the app only once. If > you have multiple Apache children workers it will compile once for > each children, so it might look like it's reloading if you hit a > worker with no compiled result. To avoid that you can preload the apps > in the httpd.conf. These are documented in the POD docs.
> sorry for my poor working - what I meant is that if you run e.g. a dancer
application using starman and make some changes you need to restart starman to see the changes. This isn't the case with Plack::Handler::Apache2 hence the possible confusion in the dancer list :
"...The reason you don't need restarts is because it loads everything on every request, like with CGI. That's slow and horrible. mod_perl has startup.pl[1] which helps deal with it, and on the Plack::Handler::Apache2 there's an example in the synopsis on handling the same thing...." "....There's a difference between "slow and horrible" and incorrect. You're not doing anything incorrectly! :) The set up you have with Plack::Handler::Apache2 is correct but not optimal..."
hence my confusion. I don't see anything slow and horrible with Plack::Handler::Apache2 but, as I do have limited experience with perl app, I thought I would ask directly on this list. My benchmark shows that Plack::Handler::Apache2 is at least as fast.
> > On a totally unrelated note you might consider adding a > donation/sponsorship > > link to your page? I would be happy to show some support to your amazing > > work!
> You can buy and promote the book http://handbook.plackperl.org/ to > give me a little bit of money, but otherwise I don't take donation nor > sponsorship for developments because money isn't my motivation and i > don't need a financial support. I would gladly take beer offers at > conferences party though :)
Understood. I will buy a copy :) thanks again for your wonderful work that is much appreciated. I feel that you have taken perl web deployment to a totally new level. Regards David
On Sep 23, 2012, at 8:55 AM, gurugeek <1...@1.ai> wrote:
> I don't understand what you mean by "Plack::Handler server script",
> but Plack::Handler::Apache2 definitely compiles the app only once. If
> you have multiple Apache children workers it will compile once for
> each children, so it might look like it's reloading if you hit a
> worker with no compiled result. To avoid that you can preload the apps
> in the httpd.conf. These are documented in the POD docs.
> sorry for my poor working - what I meant is that if you run e.g. a dancer
application
using starman and make some changes you need to restart starman to see the
changes.
This isn't the case with Plack::Handler::Apache2
This _is_ the case unless you do some custom hackery on your own to enable
reloading with middleware etc.
hence the possible confusion in the dancer list :
"...The reason you don't need restarts is because it loads everything on
every request, like with CGI. That's slow and horrible. mod_perl has
startup.pl[1] which helps deal with it, and on the Plack::Handler::Apache2
there's an example in the synopsis on handling the same thing...."
"....There's a difference between "slow and horrible" and incorrect. You're
not doing anything incorrectly! :)
The set up you have with Plack::Handler::Apache2 is correct but not
optimal..."
Sounds like they don't know what they are talking about or confused with
mod_perl to run cgi scripts with Plack::Handler::CGI, which is quite
different from using Plack apache2 handler.
hence my confusion. I don't see anything slow and horrible
with Plack::Handler::Apache2 but, as I do have limited experience with
perl app, I thought I would ask directly on this list. My benchmark shows
that Plack::Handler::Apache2 is at least as fast.
> > On a totally unrelated note you might consider adding a
> donation/sponsorship
> > link to your page? I would be happy to show some support to your amazing
> > work!
> You can buy and promote the book http://handbook.plackperl.org/ to
> give me a little bit of money, but otherwise I don't take donation nor
> sponsorship for developments because money isn't my motivation and i
> don't need a financial support. I would gladly take beer offers at
> conferences party though :)
Understood. I will buy a copy :) thanks again for your wonderful work that
is much appreciated. I feel that you have taken perl web deployment to a
totally new level.
Regards
David
>> sorry for my poor wording - what I meant is that if you run e.g. a dancer > application > using starman and make some changes you need to restart starman to see the > changes. > This isn't the case with Plack::Handler::Apache2
> This _is_ the case unless you do some custom hackery on your own to enable > reloading with middleware etc.
If this is the case how does the reload takes place ? When you upload a new file / save the file ? As you might know in passenger you need to do something like touch /tmp/restart.txt so it is the first thing I tried in the dancer app running using Plack::Handler::Apache2 and how it works with my standard installation is once the file is edited and saved (or uploaded from SFTP) the new modified app is up and running with no restart needed. Sorry again if I am missing a simple point here.
> Sounds like they don't know what they are talking about or confused with > mod_perl to run cgi scripts with Plack::Handler::CGI, which is quite > different from using Plack apache2 handler.
> Great to know that this is not such an ugly solution :)
On Sep 23, 2012, at 10:51 AM, gurugeek <1...@1.ai> wrote:
>> sorry for my poor wording - what I meant is that if you run e.g. a dancer
> application
> using starman and make some changes you need to restart starman to see the
> changes.
> This isn't the case with Plack::Handler::Apache2
> This _is_ the case unless you do some custom hackery on your own to enable
> reloading with middleware etc.
If this is the case how does the reload takes place ?
It doesn't take place automatically. You have to restart the httpd process.
When you upload a new file / save the file ? As you might know in passenger
you need to do something like touch /tmp/restart.txt so it is the first
thing I tried in the dancer app running using Plack::Handler::Apache2 and
how it works with my standard installation is once the file is edited and
saved (or uploaded from SFTP) the new modified app is up and running with
no restart needed.
As I said that shouldn't happen unless you enable custom reloading with
middleware or you have multiple of workers that somehow don't have the code
compiled.
OR, you configure Plack apache2 handler in a weird way that does things i
can't expect. You haven't showed us your exact configuration yet so we can
only guess.
Sorry again if I am missing a simple point here.
> Sounds like they don't know what they are talking about or confused with
> mod_perl to run cgi scripts with Plack::Handler::CGI, which is quite
> different from using Plack apache2 handler.
> Great to know that this is not such an ugly solution :)
and the changes took effect when I reloaded the page I am actually not complaining about the auto-reload which is, in fact, very useful. So this is just FYI. Thank you David
That configuration doesn't seem to reload your app. You can look at the
handler module code which is like 50 lines of code you can see the app is
cached off of a file name.
Your app getting reloaded is a mystery or some bug or misconfiguration.
Sent from my iPhone
On Sep 23, 2012, at 11:59 AM, gurugeek <1...@1.ai> wrote:
I am running apache with the AssignUserID directive and a the standard
configuration without any tweaking
and the changes took effect when I reloaded the page
I am actually not complaining about the auto-reload which is, in fact, very
useful. So this is just FYI. Thank you
David