Discussion:
[Mason-devel] Mason + FastCGI
Pedro Melo
2009-09-30 17:24:52 UTC
Permalink
Hello,

I would like to use Mason under FastCGI. I did a small experiment (http://github.com/melo/exp-mason-fcgi
) and found some things that don't work that well when Mason runs
outside Apache.

I'm preparing cleaned up patches to work around those issues.

Is this something that you would be interested on?

My current plan is:

* create a FastCGIHandler class to hide all the FCGI specific code;
* create a small distribution HTML::Mason::FastCGI that include the
Handler and a startup script (like Catalyst has);
* fix some issues with directory requests.

I also have a patch to implement $m->scall_next() (a call_next() that
uses scomp()). Is this something that you would take?


Also, I see that the development is using SVN. For my personal
purposes I created a git repo with a proper authors file. Not sure
about two authors though (swartz == jswartz? sharkey == sharkey3?). If
you like, I can also make the authors file available.

Bye,
Jonathan Swartz
2009-09-30 18:06:20 UTC
Permalink
Hi Pedro,

That would be interesting to me, at least. I'm curious what things
don't work with the regular CGI handler.

I'm sure Dave would say, "why don't you just use Catalyst with Mason"?
But I expect you have a reason, given that you are obviously aware of
Catalyst. :)

Jon
Post by Pedro Melo
Hello,
I would like to use Mason under FastCGI. I did a small experiment (http://github.com/melo/exp-mason-fcgi
) and found some things that don't work that well when Mason runs
outside Apache.
I'm preparing cleaned up patches to work around those issues.
Is this something that you would be interested on?
* create a FastCGIHandler class to hide all the FCGI specific code;
* create a small distribution HTML::Mason::FastCGI that include the
Handler and a startup script (like Catalyst has);
* fix some issues with directory requests.
I also have a patch to implement $m->scall_next() (a call_next() that
uses scomp()). Is this something that you would take?
Also, I see that the development is using SVN. For my personal
purposes I created a git repo with a proper authors file. Not sure
about two authors though (swartz == jswartz? sharkey == sharkey3?). If
you like, I can also make the authors file available.
Bye,
------------------------------------------------------------------------------
Come build with us! The BlackBerry® Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart
your
developing skills, take BlackBerry mobile applications to market and
stay
ahead of the curve. Join us from November 9-12, 2009. Register
now!
http://p.sf.net/sfu/devconf
_______________________________________________
Mason-devel mailing list
https://lists.sourceforge.net/lists/listinfo/mason-devel
Hans Dieter Pearcey
2009-09-30 18:14:51 UTC
Permalink
Post by Jonathan Swartz
That would be interesting to me, at least. I'm curious what things
don't work with the regular CGI handler.
Me too. As far as I know, I fixed all of them a few years ago. Maybe some of
those patches are still languishing unapplied somewhere.

hdp.
Pedro Melo
2009-09-30 19:46:03 UTC
Permalink
Post by Hans Dieter Pearcey
Post by Jonathan Swartz
That would be interesting to me, at least. I'm curious what things
don't work with the regular CGI handler.
Me too. As far as I know, I fixed all of them a few years ago.
Maybe some of
those patches are still languishing unapplied somewhere.
See previous message for the description of my main concern, dealing
with directory requests.

For reference, my fastcgi.pl script is here.

After I answered Jonathan, I remembered my other problem: how to deal
with 404, 500, and 301 answers from Mason undef FastCGI.

I need to look a bit more into this part, but if you use FastCGI with
Mason, I would appreciate your comments.

Best regards,
Pedro Melo
2009-09-30 19:42:51 UTC
Permalink
Hi,
Post by Jonathan Swartz
That would be interesting to me, at least. I'm curious what things
don't work with the regular CGI handler.
Maybe I used the wrong word. Is not that it doesn't work, but Mason
assumes that Apache will do some of the work with directory requests.

If you have a /index.html and you request the /, the standard Mason
will not find index.html because that part is usually done by Apache
and its DirectoryIndex directive. And yes, I know about the rewrite
tricks that you can do but still, I would prefer a in-Mason solution.

What I did on my experimental Mason, was this:

(before you look at the code, please read the commit message. Yes,
this is the wrong fix, it should be inside the Interp.pm code, but I
was in a hurry at the time and this was a proof-of-concept)

http://github.com/melo/exp-mason-fcgi/commit/2360faa2c94f44b2be4f4cce6dbdcbfdbb788107

Basically if we can't find the component for the request, we will try
to find index.html and index.htm. The names are hardcoded in this
experiment. In a real patch, I would make that an option to the Interp
class, something like directory_index => ['index.html', 'index.htm']
Post by Jonathan Swartz
I'm sure Dave would say, "why don't you just use Catalyst with
Mason"? But I expect you have a reason, given that you are obviously
aware of Catalyst. :)
Its a good question, but I did my homework on this one :). Basically
Catalyst doesn't add any value to this site:

* I don't need multiple views per controller, only straight HTML;
* all my Model's are alteady abstracted away;
* the URLs are pretty simple, I don't need any chaining stuff.

Besides, the development environment of Mason is much better IMHO. I
don't have to restart the app_server.pl everytime I change stuff, only
when the models change.

And I think that Mason has better performance on production
environment: the component preload, and the static_source features are
awesome.

But, even if I make a bad decision right now, and the site grows to a
point where Cat is actually a better solution, I can still reuse all
my Mason components as a Cat view.

So picking Mason right now has no down-side for this site.

Best regards,
Hans Dieter Pearcey
2009-09-30 20:25:26 UTC
Permalink
Post by Pedro Melo
Post by Jonathan Swartz
I'm sure Dave would say, "why don't you just use Catalyst with
Mason"? But I expect you have a reason, given that you are obviously
aware of Catalyst. :)
Its a good question, but I did my homework on this one :). Basically
* I don't need multiple views per controller, only straight HTML;
* all my Model's are alteady abstracted away;
These are strange things to give as reasons to not use Catalyst. Both View and
Model in Catalyst are pretty thin -- most of the Views are a tiny wrapper
around a templating engine, and most of the Models are a tiny wrapper around
some external class. Not using Catalyst because you didn't need those misses
the point -- it's like saying "I didn't use Perl because I don't need to
emulate awk's line-splitting behavior."
Post by Pedro Melo
* the URLs are pretty simple, I don't need any chaining stuff.
Hardcoding URLs all over the place is still a bad idea. $c->uri_for was useful
before Chained became popular, and it continues to be useful independent of
Chained, because it takes things like protocol, hostname, port, and SCRIPT_NAME
into account.

If you'd said:

* I'm always running my app under a single environment (FastCGI), and I don't
care about having a standalone dev server
* I don't need a separate webserver-independent config file for my app
* My app will never need to change internal structure while maintaining its
current URL layout
* My app will never live under any path other than / (or wherever it is
right now)

I might not believe you on all those points, but you'd at least be saying that
you don't need the core things that Catalyst provides. (The other feature I
think of as "core Catalyst" is the plugin architecture, which I've left out
because subclassing HTML::Mason::Request is close enough, though that has its
own gotchas too.)
Post by Pedro Melo
Besides, the development environment of Mason is much better IMHO. I
don't have to restart the app_server.pl everytime I change stuff, only
when the models change.
Are you aware of the -r option (restart) to myapp_server.pl in Catalyst?
Post by Pedro Melo
And I think that Mason has better performance on production
environment: the component preload, and the static_source features are
awesome.
Premature optimization, and in any case, is this based on anything more than a
guess?
Post by Pedro Melo
But, even if I make a bad decision right now, and the site grows to a
point where Cat is actually a better solution, I can still reuse all
my Mason components as a Cat view.
Only if you are very disciplined about segregating components that use web
framework features (cookies, etc.) from those which use only templating
features; otherwise you'll need to go back through them all again.

All that said, it's your app, and you should optimize for your time as a
developer. If you are comfortable with what Mason gives you and aren't
interested in learning (more) Catalyst at this point, go for it. My intent is
to correct what I think are your mistaken impressions about Catalyst, not to
tell you that using Mason as a standalone framework is always wrong.

hdp.
Pedro Melo
2009-09-30 21:35:16 UTC
Permalink
Hi Hans,
Post by Hans Dieter Pearcey
Post by Pedro Melo
Post by Jonathan Swartz
I'm sure Dave would say, "why don't you just use Catalyst with
Mason"? But I expect you have a reason, given that you are obviously
aware of Catalyst. :)
Its a good question, but I did my homework on this one :). Basically
* I don't need multiple views per controller, only straight HTML;
* all my Model's are alteady abstracted away;
These are strange things to give as reasons to not use Catalyst.
Both View and
Model in Catalyst are pretty thin -- most of the Views are a tiny wrapper
around a templating engine, and most of the Models are a tiny
wrapper around
some external class.
The second reason was more of a explanation that I can move from one
to the other easily because all my "models" (aka business logic) is
already on a set of Moose objects totally outside Cat.

The first reason is actually a good reason. If I needed to generate
both a site and a RESTy API, Catalyst would be much better because I
can reuse all the dispatching logic, all the controller logic, and
just use a different view for each one.

In my case I don't need that, so I don't need the flexibility of
multiple Views that you get from Cat.
Post by Hans Dieter Pearcey
Not using Catalyst because you didn't need those misses
the point -- it's like saying "I didn't use Perl because I don't need to
emulate awk's line-splitting behavior."
I don't think it does. Cat is more complex than Mason. To add a new
page, I need to tweak a controller, and then create the template file.
I need to keep those two in sync.

With Mason, I just add the page. Simple as that.

So if my site is actually simple and doesn't need Cat features, I
think I'm better served with a simpler solution, Mason.

KISS at work.
Post by Hans Dieter Pearcey
Post by Pedro Melo
* the URLs are pretty simple, I don't need any chaining stuff.
Hardcoding URLs all over the place is still a bad idea. $c->uri_for was useful
before Chained became popular, and it continues to be useful
independent of
Chained, because it takes things like protocol, hostname, port, and SCRIPT_NAME
into account.
I have a draft article on my blog why uri_for is a bad solution in
certain situations. uri_for is only available if you have a $c object
*for the target site*.

If you have both a front-office and a back-office site then you can't
use uri_for in the back-office to generate a link to a action in the
front-office, it just wont work.

But yes, hardcoding URLs would be a big mistake. And we don't do it
for a long time (before Cat and uri_for() existed even). What we do at
$work is this: we create a App::URI class with a method for each
public URL that we have, on all the sites. For example, we would have
a "member_area()" that would take a $member object or a $member_id
scalar, and (based on the current environment, like ENV, any Request
objects he has access to, phase of the moon, whatever), spits out the
proper URL.

For example, in our cat apps, our top level Root auto action has
something like this:

$c->stash->{u} = App::URI->new( base => $c->req->base );

Depending on the the needs, some App::URI's are more complex than
others. For example, I have one that based on a user cookie, generates
different URLs for 'base', allowing me to redirect a specific user
that is having problems to a different server for further analysis. A
live "lets debug *this* user" click on the back-office, and presto -
all accesses for that user switch to a new server, usually with debug
on.

On Mason, I don't have a perfect solution to keep this 'u' object
alive per request. Right now, I'm using a Guard object to clear a
global HTML::Mason::Commands::u so each component can just $u-
Post by Hans Dieter Pearcey
method() anywhere, and this $u will be cleaned up at the end of my
Mason handler.

I guess I could just use notes/pnotes, but just using $u is easier.

So yes, uri_for is "nice" but only works if you can get a $c for the
site where the URL you want is located, and that is not always
accessible.

The tradeoff is that I need to keep these two in sync, the App::URL
class and the layout on disk of my Mason components. Its a tradeoff
that works for me for now, but might not work for you. I do like the
fact that I can use $member_object or $member_id as parameters to my
App::URL methods though.

Something for the future: I could probably extract my App::URI from
the Cat internals, walking the Dispatcher internals.

Also for future testing: on the Mason side, I could also create a <
%method> on each component with a specific name to house the methods
of my App::URI class and walk the in memory component cache to fetch
them, but this only work if we preloaded all the components to memory.
Post by Hans Dieter Pearcey
* I'm always running my app under a single environment (FastCGI), and I don't
care about having a standalone dev server
I don't. Even for Catalyst I develop with the app_fastcgi.pl script
under a local nginx on the laptop. It makes a lot of sense to have
this setup because I don't have do deal with static content on the dev
side. Usually you would use the Plugin::Static and then on production
switch to a nginx/lighttpd server for static, forwarding the rest to
fastcgi.

I just start as fastcgi. The startup time is the same, and with -d the
same debug features are there.
Post by Hans Dieter Pearcey
* I don't need a separate webserver-independent config file for my app
I don't understand this one.
Post by Hans Dieter Pearcey
* My app will never need to change internal structure while
maintaining its
current URL layout
If it ever does this, I would rather write mod_rewrite rules, in C,
fast, than deal with that on the App site.

It makes more sense to me to use the fast and expressive rewrite
engines that lighhtpd/nginx have than any other solution.

For example, to skip dhandlers I sometimes rewrite /user/ID into /
user/?id=ID.
Post by Hans Dieter Pearcey
* My app will never live under any path other than / (or wherever it is
right now)
This is true, they wont.

If they did, it is very simple to mkdir path and mv * path, and adjust
my App::URI class.

The way I have my App::URi's I would bet that I would only need to
change one line.
Post by Hans Dieter Pearcey
I might not believe you on all those points, but you'd at least be saying that
you don't need the core things that Catalyst provides.
I guess I failed to explain myself. My main point was exactly that: I
don't need most of what Cat does for me.

Mason is simpler, faster (but framework overhead is meaningless most
of time, given that database access will be your bottleneck), and
easier to develop on.

Also, Mason has a lot of upside:

* cache is builtin: this is *huge* for us; the fact that I can cache
each component individually is so flexible (and I can expand this
point if you want me to);
* development is simpler: no dev server restart for most of the
changes, only when Model classes change.
* production mode (preloading, static source) is wonderful.

Some of those items could be implemented with Cat, for sure, but they
are not core.
Post by Hans Dieter Pearcey
(The other feature I
think of as "core Catalyst" is the plugin architecture, which I've left out
because subclassing HTML::Mason::Request is close enough, though that has its
own gotchas too.)
I don't use Plugins much with Cat. I could expand this but it is OT
for this list. Ping me off-the-list if you want my reasons.

I do use base Controllers a bit, but I still find them limited.

I also would avoid subclassing Mason::Request...
Post by Hans Dieter Pearcey
Post by Pedro Melo
Besides, the development environment of Mason is much better IMHO. I
don't have to restart the app_server.pl everytime I change stuff, only
when the models change.
Are you aware of the -r option (restart) to myapp_server.pl in
Catalyst?
Yes. Compare that with "not having to restart". This is one of my Cat
apps:

(the Model, business logic, mostly DBIC Results/ResultSets)
find lib -type f -name \*.pm | wc -l
370

(the Cat app)
find site/WMG/lib -type f -name \*.pm | wc -l
61

Restarting the dev server is measured in seconds, multiple seconds.
Compare that with not having to restart most of the time.

My Model workflow is simple:

* tweak test case;
* tweak model while:
* run test case until it passes.

Then I restart the dev server and tweak components without further
restarts.
Post by Hans Dieter Pearcey
Post by Pedro Melo
And I think that Mason has better performance on production
environment: the component preload, and the static_source features are
awesome.
Premature optimization, and in any case, is this based on anything more than a
guess?
No, ab and siege results for my particular app.

And you should read the entire phrase to understand where that part
"Premature optimization is the root of all evil" was used. I'll do
that for you and highlight the part that I think applies in this case:

(Knuth paper is here: http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.103.6084&rep=rep1&type=pdf
, quote is on page 8, second column, search for evil)

We should forget about small efficiencies, say about 97% of the
time: premature optimization is the root of all evil. **Yet we should
not pass up our opportunity** in that critical 3%.

I see component preload and static_source as a easy 3% that doesn't
cost me nothing (in my case memory is cheap).

Also, it adds a nice side effect. You can update the files to a new
version without worrying about your App mixing old and new components.
Not that I would depend on that side-effect for important sites, but
it is useful in some situations.

For example, this is an old site, I don't recommend this anymore, but
it was useful at the time: I have two mod_perl app servers on the same
component roots in production. The production is running with
static_source, the pre-production is not. I can upload new versions of
the component, do some live testing on the pre-production server, and
restart the production server when I'm sure everything is ok.

Of course if the production server crashes it will see the new files,
and thats why I don't use this anymore, but it is nice :).
Post by Hans Dieter Pearcey
Post by Pedro Melo
But, even if I make a bad decision right now, and the site grows to a
point where Cat is actually a better solution, I can still reuse all
my Mason components as a Cat view.
Only if you are very disciplined about segregating components that use web
framework features (cookies, etc.) from those which use only
templating
features; otherwise you'll need to go back through them all again.
Cookies are usually abstracted on my apps.

But sure, you need to be careful with that. But I don't think that
this part would be much code to rewrite, compared to all the templates.
Post by Hans Dieter Pearcey
All that said, it's your app, and you should optimize for your time as a
developer. If you are comfortable with what Mason gives you and aren't
interested in learning (more) Catalyst at this point, go for it.
:)

I started with Cat 5.005 more than 3 or 4 years ago, and have wrote
and put to production about 10 sites using it. The biggest was the one
I mentioned before in this email.

Please understand that my decision to choose Mason was not of a
beginner. It was well though out, and based on my experience of Mason
since 1999 when I did a webmail Mason powered for 300k users.

Also I do like Cat, a lot, but I don't think its the answer to all of
the world problems. I do think Mason is a excellent framework, with a
lot of upside over Cat *if* you are disciplined enough. I would agree
that Cat gives a more consistent framework in some areas, but Mason is
no slouch.

But my problem with Mason is the deployment phase. Right now it is
very much geared towards mod_perl and that is something that we would
like to remove from our tool chain, and move to FastCGI.

Hence my presence here: to improve Mason FastCGI experience.
Post by Hans Dieter Pearcey
My intent is
to correct what I think are your mistaken impressions about Catalyst,
Well, maybe I'm mistaken about Cat, I don't think so, I do know it
pretty well. I might have failed to explain my reasons on my first
attempt. I hope to have done better this time.

Best regards,
Hans Dieter Pearcey
2009-10-01 01:41:42 UTC
Permalink
Post by Pedro Melo
Post by Hans Dieter Pearcey
* I don't need a separate webserver-independent config file for my app
I don't understand this one.
It's a reference to ConfigLoader (vs. e.g. PerlSetVar in httpd.conf).
Post by Pedro Melo
If it ever does this, I would rather write mod_rewrite rules, in C,
fast, than deal with that on the App site.
Of course, then you're tied to a specific webserver; this also assumes that the
URL is the only difference, as opposed to needing to munge query string
arguments or provide different defaults for them or whatever.
Post by Pedro Melo
I guess I failed to explain myself. My main point was exactly that: I
don't need most of what Cat does for me.
OK; then why not use only what you need? It'd be trivial to write an app whose
Controller::Root had a single action (at /, with any number of args) that
handed off to a Mason view to do the real work. You get fastcgi and the
standalone server for free AND the Mason component reloading that you enjoy so
much.

(Even better would be for Mason to work on PSGI, but that's not a useful
suggestion right now.)
Post by Pedro Melo
Post by Hans Dieter Pearcey
My intent is
to correct what I think are your mistaken impressions about Catalyst,
Well, maybe I'm mistaken about Cat, I don't think so, I do know it
pretty well. I might have failed to explain my reasons on my first
attempt. I hope to have done better this time.
At first you sounded like someone who'd heard a few things about Catalyst and
maybe tried it once and thought it was for Big Enterprisey Projects but not for
smaller things.

It's a relief to find that this isn't the case, because it didn't fit with my
vague memory of you.

hdp.
Pedro Melo
2009-10-01 06:55:28 UTC
Permalink
Hi,
Post by Hans Dieter Pearcey
Post by Pedro Melo
Post by Hans Dieter Pearcey
* I don't need a separate webserver-independent config file for my app
I don't understand this one.
It's a reference to ConfigLoader (vs. e.g. PerlSetVar in httpd.conf).
Ahh. Well, with Mason I usually write my own handler code. More out of
habit that anything else.
Post by Hans Dieter Pearcey
Post by Pedro Melo
If it ever does this, I would rather write mod_rewrite rules, in C,
fast, than deal with that on the App site.
Of course, then you're tied to a specific webserver; this also
assumes that the
URL is the only difference, as opposed to needing to munge query string
arguments or provide different defaults for them or whatever.
Well, this is very rare, so not a concern. But as long as the
webserver config files are version controlled and your test suite
checks the old URLs for proper redirects and/or the same content as
previously, I really don't mind.

Changing Webservers is rare. It does happen. I switching recently from
lighttpd to nginx because I grew tired of the memory leaks. But it is
rare...
Post by Hans Dieter Pearcey
Post by Pedro Melo
I guess I failed to explain myself. My main point was exactly that: I
don't need most of what Cat does for me.
OK; then why not use only what you need? It'd be trivial to write an app whose
Controller::Root had a single action (at /, with any number of args) that
handed off to a Mason view to do the real work. You get fastcgi and the
standalone server for free AND the Mason component reloading that you enjoy so
much.
That would work, but isn't that a bit extreme? Use the entire Cat
stack just to get FastCGI?
Post by Hans Dieter Pearcey
(Even better would be for Mason to work on PSGI, but that's not a useful
suggestion right now.)
Exactly. I talked to miyagawa a week or two ago about this, but I felt
that PSGI was still immature. I do think that a HandlerPSGI would be
great, specially to embed small Mason-based admin interfaces inside
AnyEvent daemons.

It would be great to have it now, because I could just reuse other
peoples FastCGI stuff, or even the embedded PSGI module that someone
is working on for nginx.
Post by Hans Dieter Pearcey
Post by Pedro Melo
Post by Hans Dieter Pearcey
My intent is
to correct what I think are your mistaken impressions about
Catalyst,
Well, maybe I'm mistaken about Cat, I don't think so, I do know it
pretty well. I might have failed to explain my reasons on my first
attempt. I hope to have done better this time.
At first you sounded like someone who'd heard a few things about Catalyst and
maybe tried it once and thought it was for Big Enterprisey Projects but not for
smaller things.
I think that everything has its place, and that Mason has a different
set of strong points than Cat. And in my particular case, they fit
better for this site.

Best regards,
Pedro Melo
2009-10-01 07:02:00 UTC
Permalink
Hi again,
Post by Pedro Melo
Post by Hans Dieter Pearcey
(Even better would be for Mason to work on PSGI, but that's not a useful
suggestion right now.)
Exactly. I talked to miyagawa a week or two ago about this, but I
felt that PSGI was still immature. I do think that a HandlerPSGI
would be great, specially to embed small Mason-based admin
interfaces inside AnyEvent daemons.
It would be great to have it now, because I could just reuse other
peoples FastCGI stuff, or even the embedded PSGI module that someone
is working on for nginx.
Well, apparently miyagawa thinks we are ready :)

http://github.com/miyagawa/HTML-Mason-PSGIHandler

I'll look into that one, with the FastCGI Impl.

Best regards,
Hans Dieter Pearcey
2009-10-01 12:09:31 UTC
Permalink
Post by Pedro Melo
Post by Hans Dieter Pearcey
OK; then why not use only what you need? It'd be trivial to write an app whose
Controller::Root had a single action (at /, with any number of args) that
handed off to a Mason view to do the real work. You get fastcgi and the
standalone server for free AND the Mason component reloading that you enjoy so
much.
That would work, but isn't that a bit extreme? Use the entire Cat
stack just to get FastCGI?
* FastCGI
* standalone dev server
* futureproofing

I don't understand saying "the entire Cat stack". It's not like I'm pulling in
a session module and an ORM and a form builder and a twitter client -- it's
just a HTTP abstraction and a URI dispatcher[1]. If we were talking about
Jifty I might get where you're coming from.

hdp.

1. OK, it's also a logger and some debug stuff. Those both lightweight and
worth it to me anyway.
Hans Dieter Pearcey
2009-10-01 13:07:19 UTC
Permalink
Catalyst will add *something* to memory footprint, startup time, and
per-request execution time, no matter how lightly you are using its
features. It doesn't exactly seem like a ::Tiny module.
I'm going to assume your straw man is unintentional: I didn't say Catalyst was
free, I said I thought that using it just for the HTTP abstraction would not
pull in tons of extra baggage (and so the development time saved would be worth
it to me).

Preferring PSGI to Catalyst for that seems reasonable to me. Putting more
effort into fastcgi for Mason doesn't, but it's the OP's time, not mine.

hdp.
Pedro Melo
2009-10-01 15:24:56 UTC
Permalink
Post by Hans Dieter Pearcey
Catalyst will add *something* to memory footprint, startup time, and
per-request execution time, no matter how lightly you are using its
features. It doesn't exactly seem like a ::Tiny module.
I'm going to assume your straw man is unintentional: I didn't say Catalyst was
free, I said I thought that using it just for the HTTP abstraction would not
pull in tons of extra baggage (and so the development time saved would be worth
it to me).
Not pull extra baggage? :) My personal Cat cost is mostly zero, given
that my models already use Moose, but compared to other alternatives,
it is extra baggage already.

My current HandlerFastCGI is 20 lines of code...
Post by Hans Dieter Pearcey
Preferring PSGI to Catalyst for that seems reasonable to me.
Putting more
effort into fastcgi for Mason doesn't, but it's the OP's time, not mine.
+1. If it becomes stable enough and doesn't get over-engineered, PSGI
will be interesting to me.

Until then, I'll stick with what I can find on CPAN and help out on
HandlerPSGI as I can.

Bye
Jonathan Swartz
2009-10-01 16:55:32 UTC
Permalink
Post by Hans Dieter Pearcey
Catalyst will add *something* to memory footprint, startup time, and
per-request execution time, no matter how lightly you are using its
features. It doesn't exactly seem like a ::Tiny module.
I'm going to assume your straw man is unintentional: I didn't say Catalyst was
free, I said I thought that using it just for the HTTP abstraction would not
pull in tons of extra baggage (and so the development time saved would be worth
it to me).
Preferring PSGI to Catalyst for that seems reasonable to me.
Putting more
effort into fastcgi for Mason doesn't, but it's the OP's time, not mine.
I agree with all that.
Jonathan Swartz
2009-10-01 12:45:33 UTC
Permalink
Post by Hans Dieter Pearcey
Post by Pedro Melo
Post by Hans Dieter Pearcey
OK; then why not use only what you need? It'd be trivial to write an app whose
Controller::Root had a single action (at /, with any number of args) that
handed off to a Mason view to do the real work. You get fastcgi and the
standalone server for free AND the Mason component reloading that you enjoy so
much.
That would work, but isn't that a bit extreme? Use the entire Cat
stack just to get FastCGI?
* FastCGI
* standalone dev server
* futureproofing
I don't understand saying "the entire Cat stack". It's not like I'm pulling in
a session module and an ORM and a form builder and a twitter client -- it's
just a HTTP abstraction and a URI dispatcher[1]. If we were talking about
Jifty I might get where you're coming from.
hdp.
1. OK, it's also a logger and some debug stuff. Those both
lightweight and
worth it to me anyway.
Catalyst will add *something* to memory footprint, startup time, and
per-request execution time, no matter how lightly you are using its
features. It doesn't exactly seem like a ::Tiny module. I haven't
benchmarked to see what this is over straight Mason.

Hans, feel like doing a quick benchmark since you already clearly have
Catalyst installed? :)

Jon
Pedro Melo
2009-10-01 15:26:06 UTC
Permalink
Hello,
Post by Hans Dieter Pearcey
Post by Pedro Melo
Post by Hans Dieter Pearcey
OK; then why not use only what you need? It'd be trivial to write an app whose
Controller::Root had a single action (at /, with any number of
args)
that
handed off to a Mason view to do the real work. You get fastcgi
and
the
standalone server for free AND the Mason component reloading that you enjoy so
much.
That would work, but isn't that a bit extreme? Use the entire Cat
stack just to get FastCGI?
* FastCGI
* standalone dev server
* futureproofing
I don't understand saying "the entire Cat stack". It's not like I'm pulling in
a session module and an ORM and a form builder and a twitter client -- it's
just a HTTP abstraction and a URI dispatcher[1]. If we were talking about
Jifty I might get where you're coming from.
hdp.
1. OK, it's also a logger and some debug stuff. Those both
lightweight and
worth it to me anyway.
Catalyst will add *something* to memory footprint, startup time, and
per-request execution time, no matter how lightly you are using its
features. It doesn't exactly seem like a ::Tiny module. I haven't
benchmarked to see what this is over straight Mason.
Hans, feel like doing a quick benchmark since you already clearly have
Catalyst installed? :)
Benchmark of what? I've done a lot of those in the last few weeks to
decide this, so I might be able to answer your curiosity.

Bye,
Mike Slattery
2009-10-01 15:38:44 UTC
Permalink
Pedro, Hans et al.,

Hi guys, I am excited to see traffic here. Pedro, I first read of
your work when looking at AnyEvent, then Mojo. I'm curious if you'd
use Mason with Mojo, but if this is all painfully OT I'd be happy to
move off list, maybe to the mason-users list. This discussion could
be germane as an offshoot of the Mason 2.0: Mason::Template and
Mason::Framework topics?

I'd love to see a separate interop page on the wiki, too, with
examples and/or pointers to apps using Mason underneath another
framework. I got into Mason via Bricolage, where I came to love the
autohandler and dhandler world of Mason, as well as templating in perl
and not a separate templating language. The new decades are steering
me toward keeping Mason around but trying other frameworks for various
situations. I'm not sure how much of Mason gets lost/improved on/
etc with Cat and/or Mojo using Mason.

Cheers,
Mike
Post by Hans Dieter Pearcey
Post by Pedro Melo
Post by Hans Dieter Pearcey
OK; then why not use only what you need? It'd be trivial to write an app whose
Controller::Root had a single action (at /, with any number of
args)
that
handed off to a Mason view to do the real work. You get fastcgi
and
the
standalone server for free AND the Mason component reloading that you enjoy so
much.
That would work, but isn't that a bit extreme? Use the entire Cat
stack just to get FastCGI?
* FastCGI
* standalone dev server
* futureproofing
I don't understand saying "the entire Cat stack". It's not like I'm pulling in
a session module and an ORM and a form builder and a twitter client -- it's
just a HTTP abstraction and a URI dispatcher[1]. If we were talking about
Jifty I might get where you're coming from.
hdp.
1. OK, it's also a logger and some debug stuff. Those both
lightweight and
worth it to me anyway.
Catalyst will add *something* to memory footprint, startup time, and
per-request execution time, no matter how lightly you are using its
features. It doesn't exactly seem like a ::Tiny module. I haven't
benchmarked to see what this is over straight Mason.
Hans, feel like doing a quick benchmark since you already clearly have
Catalyst installed? :)
Jon
------------------------------------------------------------------------------
Come build with us! The BlackBerry&reg; Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart
your
developing skills, take BlackBerry mobile applications to market and
stay
ahead of the curve. Join us from November 9&#45;12, 2009. Register
now&#33;
http://p.sf.net/sfu/devconf
_______________________________________________
Mason-devel mailing list
https://lists.sourceforge.net/lists/listinfo/mason-devel
Pedro Melo
2009-10-01 15:56:10 UTC
Permalink
Post by Mike Slattery
Pedro, Hans et al.,
Hi guys, I am excited to see traffic here. Pedro, I first read of
your work when looking at AnyEvent, then Mojo. I'm curious if you'd
use Mason with Mojo, but if this is all painfully OT I'd be happy to
move off list, maybe to the mason-users list.
Mason + Mojo: not at this time.

Theoretically, if you get PSGI::Impl::Mojo + Mason::HandlerPSGI going,
you are home.
Post by Mike Slattery
This discussion could
be germane as an offshoot of the Mason 2.0: Mason::Template and
Mason::Framework topics?
I read about Mason 2.0, but I don't know what Mason::Template and
Mason::Framework are.

Bye,
Jonathan Swartz
2009-10-01 17:17:11 UTC
Permalink
Pedro, I believe Mike is talking about a post by Dave Rolsky a while
back (can't find it at the moment) about splitting Mason into two
parts, one with the pure template language and one with the web
framework pieces.

On http://www.openswartz.com/2009/09/01/what-mason-2-0-would-look-
like/ I made a stronger statement, which is that we could pretty much
eliminate Mason's web features. At the time I mentioned HTTP::Engine,
but I should probably replace that now with WSGI. :)

Jon
Post by Pedro Melo
Post by Mike Slattery
This discussion could
be germane as an offshoot of the Mason 2.0: Mason::Template and
Mason::Framework topics?
I read about Mason 2.0, but I don't know what Mason::Template and
Mason::Framework are.
Bye,
------------------------------------------------------------------------------
Come build with us! The BlackBerry&reg; Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart
your
developing skills, take BlackBerry mobile applications to market and
stay
ahead of the curve. Join us from November 9&#45;12, 2009. Register
now&#33;
http://p.sf.net/sfu/devconf
_______________________________________________
Mason-devel mailing list
https://lists.sourceforge.net/lists/listinfo/mason-devel
Pedro Melo
2009-10-01 15:22:06 UTC
Permalink
Hi,
Post by Hans Dieter Pearcey
Post by Pedro Melo
Post by Hans Dieter Pearcey
OK; then why not use only what you need? It'd be trivial to write an app whose
Controller::Root had a single action (at /, with any number of args) that
handed off to a Mason view to do the real work. You get fastcgi and the
standalone server for free AND the Mason component reloading that you enjoy so
much.
That would work, but isn't that a bit extreme? Use the entire Cat
stack just to get FastCGI?
* FastCGI
* standalone dev server
* futureproofing
Of these, FastCGI is true, standalone dev server is not important as I
previously explained (I don't even use for Cat apps...) and future-
proofing is a non-issue.
Post by Hans Dieter Pearcey
I don't understand saying "the entire Cat stack". It's not like I'm pulling in
a session module and an ORM and a form builder and a twitter client -- it's
just a HTTP abstraction and a URI dispatcher[1]. If we were talking about
Jifty I might get where you're coming from.
but I just need the HTTP abstraction.

PSGI is a much better fit, and probably my path is to help myiagawa to
finish the HandlerPSGI + the Impl::FastCGI.

In the mean time, I'll try my HandlerFastCGI code to keep developing.

Best regards,
David E. Wheeler
2009-10-01 16:01:21 UTC
Permalink
Post by Hans Dieter Pearcey
I don't understand saying "the entire Cat stack". It's not like I'm pulling in
a session module and an ORM and a form builder and a twitter client -- it's
just a HTTP abstraction and a URI dispatcher[1]. If we were talking about
Jifty I might get where you're coming from.
Catalyst comes with a pretty substantial overhead and dependency
chain. I just launched a simple Catalyst app I'm working on that so
far has only the default controller and no views or model, and it's
using 30MB of RAM on my MacBook Pro (using the default Catalyst
server, whatever it is). IIRC, mod_perl + Mason takes up around 2MB.

Oh, and Moose, though we all know that the overhead of Moose is
actively being worked on. Can't wait.

Best,

David
Jonathan Swartz
2009-10-01 11:44:52 UTC
Permalink
Post by Hans Dieter Pearcey
OK; then why not use only what you need? It'd be trivial to write an app whose
Controller::Root had a single action (at /, with any number of args) that
handed off to a Mason view to do the real work. You get fastcgi and the
standalone server for free AND the Mason component reloading that you enjoy so
much.
That's been my thinking about Catalyst lately as well - use it for the
engines and API and standard dir structure, and dispatch immediately
into Mason for controlling etc. Of course, it's telling that I haven't
done this for any of my pure-Mason servers yet. it's either not
trivial enough or not compelling enough.
Post by Hans Dieter Pearcey
(Even better would be for Mason to work on PSGI, but that's not a useful
suggestion right now.)
Yes, this will be wonderful. I assume by "not useful" you mean that
PSGI/Plack isn't ready for prime time yet?

Jon
Hans Dieter Pearcey
2009-10-01 11:53:59 UTC
Permalink
Post by Jonathan Swartz
Post by Hans Dieter Pearcey
(Even better would be for Mason to work on PSGI, but that's not a useful
suggestion right now.)
Yes, this will be wonderful. I assume by "not useful" you mean that
PSGI/Plack isn't ready for prime time yet?
I mostly meant that there wasn't a Mason PSGI handler, but as Pedro pointed
out: http://github.com/miyagawa/HTML-Mason-PSGIHandler (appeared yesterday).

It's true that PSGI/Plack are still settling down, but my impression is that
that's mostly in the area of plugging into async IO frameworks. If someone
told me that they were planning on deploying a PSGI app to production next
month, I wouldn't think that was crazy.

hdp.
Jonathan Swartz
2009-10-01 12:46:41 UTC
Permalink
Post by Hans Dieter Pearcey
Post by Jonathan Swartz
Post by Hans Dieter Pearcey
(Even better would be for Mason to work on PSGI, but that's not a useful
suggestion right now.)
Yes, this will be wonderful. I assume by "not useful" you mean that
PSGI/Plack isn't ready for prime time yet?
I mostly meant that there wasn't a Mason PSGI handler, but as Pedro pointed
out: http://github.com/miyagawa/HTML-Mason-PSGIHandler (appeared yesterday).
It's true that PSGI/Plack are still settling down, but my impression is that
that's mostly in the area of plugging into async IO frameworks. If someone
told me that they were planning on deploying a PSGI app to
production next
month, I wouldn't think that was crazy.
Really? Even though, AFAICT, nothing PSGI or Plack related is on CPAN?
Call me old-fashioned... :)

Jon
Loading...