Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Is Plack ready for production?

by morgon (Deacon)
on Sep 27, 2011 at 21:54 UTC ( #928191=perlquestion: print w/ replies, xml ) Need Help??
morgon has asked for the wisdom of the Perl Monks concerning the following question:

Hi,

I started looking into Plack a few days ago, I liked it from the beginning, I still do.

BUT:

At the moment I am struggeling to get a Plack-app running as fast-cgi under mod_fcgid.

Even after invesing several hours I still can't do it.

I have posted a question to this forum but don't get any responses...

I can't find any documentation covering my case not does Google help much...

I don't want to whine too much now as I am probably just being stupid but in my project I cannot seriously advocate an approach where you are on your own should you get stuck.

So my question is:

Is anyone already using Plack for mission-critical applications and is it something to recommend?

Comment on Is Plack ready for production?
Re: Is Plack ready for production?
by onelesd (Pilgrim) on Sep 27, 2011 at 22:00 UTC
    I am using it for internal software which my company uses and I have no issues with it. It just works. I'm using plackup.
Re: Is Plack ready for production?
by roubi (Hermit) on Sep 28, 2011 at 00:58 UTC
    I use mod_fcgid with a Plack app and it just works (and it works better than mod_fastcgi may I add, for whatever reason). You seem to be having an Apache configuration issue rather than a Plack issue here though?

    I'll admit it took me a little while to get my setup working, mostly having to do with understanding what path to put in a Rewrite rule location in a .htaccess file and nothing to do with Plack itself.

    What doc are you using? I started with the Dancer deployment perldoc and adapted from there: http://search.cpan.org/~xsawyerx/Dancer-1.3072/lib/Dancer/Deployment.pod. A quick Google search showed that similar documents exist for Catalyst and Mojolicious.

      Roubi, do you happen to be using mod_fcgid to run what mod_fastcgi would call a static server?   (In other words, the URL does not point to a filename; Apache (maybe) starts the server(s) when Apache is initialized.)

      I had serious troubles figuring out if mod_fcgid could do that, to the point that I wound up compiling mod_fastcgi from source for a Linux box that didn’t supply it by default.   (It’s very obvious from the docs how mod_fastcgi supports that mode.   But it’s not at all obvious to me how/if mod_fcgid does, although for this mode to be unsupported seems quite “no, this just can’t be.”)

      A snippet of the necessary config-file voodoo would be quite useful to me, if you did get it to work that way.

        I am pretty sure my setup is closer to what mod_fastcgi calls "dynamic". Apache is in charge of starting and stopping the application instances based on load, and won't do so until the first hit to the app.
        In practical terms though, the monitoring scheme we've got here should ensure that the "dynamic" app is always up and so I haven't looked at a more static-ish setup. If you do find out how to do this with mod_fcgid I'd be interested to hear about it.
Re: Is Plack ready for production?
by Anonymous Monk on Sep 28, 2011 at 02:57 UTC

    So my question is: Is anyone already using Plack for mission-critical applications and is it something to recommend?

    Yes, naturally

Re: Is Plack ready for production?
by jdrago999 (Pilgrim) on Sep 28, 2011 at 06:56 UTC

    Is anyone already using Plack for mission-critical applications and is it something to recommend?

    I currently have a Plack app which runs as part of a very, very large image viewing application (lots and lots of scanned images of legal documents). I have a multi-threaded program running with plackup. The web application currently responds to thousands of visitors daily and that number is expected to increase to millions. We have the hardware to throw at it.

    That said, if you're doing something "mission critical" perhaps look at launching your *.psgi under Starman instead of plackup. It is "high performance" and has several optimizations.

Re: Is Plack ready for production?
by sundialsvc4 (Abbot) on Sep 28, 2011 at 12:49 UTC

    Needless to say, it isn’t Plack’s fault...   :-}

    If you posted a question and didn’t get an answer, please assume it was either an accident or an oversight – or that perhaps the people who read your question did not understand your question sufficiently well enough to answer it.

    Please describe exactly what you have tried and exactly how you are getting stuck.   Details matter.

Reaped: Re: Is Plack ready for production?
by NodeReaper (Curate) on Sep 28, 2011 at 12:53 UTC
Re: Is Plack ready for production?
by sundialsvc4 (Abbot) on Sep 28, 2011 at 23:40 UTC

    Lest you think that my previous reply was “dismissive,” perhaps the following stage-setter might be useful...

    Any Plack application can be thought of as encompassing four levels, which would be (from innermost to outermost) as follows:

    1. The legacy application:   It has never heard of Plack.   It can’t even spell the name.   It was written for mod_perl or for CGI, and anytime you talk to it about “the future,” all you ever hear in response begins with... “harumph, these kids today.   Why, back in my day...”   You really don’t want to piss-off such a massive and mission-critical geriatric monolith ... especially since it is the Old Phart that makes all the money for the whole damm company.   Smile when he starts talking about how great punched paper tape was, and pretend you have never heard that story before.   Honest, you just want to fool it into thinking that “the present” is “the past.”   :-}   Perhaps just wedge a small alternate entry-point into it for Stage 2 to use, then tiptoe quietly away.
    2. The wrapper:   A new program, usually named app.psgi (since this is what plackup automatically looks for...) which is actually the routine that gets invoked when a new request comes in.   This module expects to be invoked by a “Plack Handler” (see #3 below) by means of a subroutine call.   Usually, Plack::Builder is used here.   Even though the old crotchety application thinks it’s still talking to the legacy environment that it’s used to, it’s actually talking to this wrapper and no one else.
    3. The handler:   When the application is invoked by a “real” web-server (as opposed to plackup), this defines the actual application that gets control.   (If you are using plackup, this layer is never used, because in that case plackup is “the handler.”)   One of the Plack::Handler modules are used here, depending on exactly what server is being used and exactly how the server is invoking the program.   The whole idea of Plack is that, if this arrangement should ever change, this is the one and only module that must be different:   you merely have to substitute a different ::handler.
    4. Server modules (maybe):   Modular servers, such as Apache, might require extension modules such as mod_fastcgi or mod_fcgid to transfer control to the handler in the appropriate way.   Once again, the whole idea of Plack is that you have a genuine choice here.   You can invoke a Plack program by means of, say, mod_perl or even “good ol’ CGI” as long as you use a corresponding “handler” in Stage 3.

    No matter what necessary combination of software you choose in Stages 3 and 4 (and no matter how often in the future you may change it), the software in Stages 2 and 1 is unchanged.   Even if you decide to substitute a completely different server (nginix, anyone?), once again, Stages 2 and 1 are unchanged.   (And that’s huge...)

    The plackup command-line utility is perhaps the best demonstration of Plack’s power.   plackup provides a command-line based “handler” environment (Stage 3, thus Stage 4 is N/A...) that is indistinguishable from what any web-server would provide.   Therefore, your Plack-compatible application runs exactly as it ordinarily would, since it is (not quite...) incapable of detecting the difference, and certainly does not care about it.

Reaped: Re: Is Plack ready for production?
by NodeReaper (Curate) on Sep 29, 2011 at 13:16 UTC
Re: Is Plack ready for production?
by stonecolddevin (Vicar) on Sep 30, 2011 at 21:16 UTC

    Plack is VERY production ready. I've used it in several high traffic areas with no problems. Check out Starman as well.

    Three thousand years of beautiful tradition, from Moses to Sandy Koufax, you're god damn right I'm living in the fucking past

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://928191]
Approved by ww
Front-paged by Arunbear
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (7)
As of 2014-12-25 10:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (160 votes), past polls