[Catalyst] Switching to a production server

ivorw m9tn-oh4c at xemaps.com
Tue Sep 16 20:42:43 BST 2008

Emily Heureux wrote:
> Thanks, I read your suggestions and opinions and am switching to fastcgi
> with apache.  I'd like to do this in steps:
> 1. Install FCGI::ProcManager
> 2. Run myapp_fastcgi.pl from the command line, just like myapp_server.pl
> 3. Then go through apache with mod_fastcgi.
> I am on step 2, and I am thinking that I can't do that with that fastcgi
> script like I can with myapp_server.pl.  I need to combine 2 and 3?
> E
I would do 3 before 2. Configure Apache to be ready to handle a fastcgi
connection through a socket (from the docs):

    FastCgiExternalServer /tmp/myapp.fcgi -socket /tmp/myapp.socket
    Alias /myapp/ /tmp/myapp/myapp.fcgi/
    # Or, run at the root
    Alias / /tmp/myapp.fcgi/
    # Optionally, rewrite the path when accessed without a trailing slash
    RewriteRule ^/myapp$ myapp/ [R]

Now having reloaded or restarted Apache2, you should be in a position to
point a browser at the new application, and get a 500 error page. The
logs should be able to tell you whether your Apache configuration is
doing the right thing.

>From your application user account shell, now run

$ script/myapp_fastcgi.pl -l /tmp/myapp.socket -n 2

or however many server processes you want to run.
>> -----Original Message-----
>> From: ivorw [mailto:m9tn-oh4c at xemaps.com]
>> Sent: Wednesday, September 10, 2008 1:34 AM
>> To: catalyst at lists.scsys.co.uk
>> Subject: Re: [Catalyst] Switching to a production server
>> Emily Heureux wrote:
>>> Hi, I have been developing a Catalyst application and just using the
>>> Catalyst myapp_server.pl script to run it.  We server a very small
>>> market, currently less than 100 visits a day.  The major issue we are
>>> having is that even small images are loaded very slowly, and therefore
>>> the pages are loaded slowly, on the order of more than 5 seconds for a
>>> first time visitor.
>>> At this time, I don't know anything about fast_cgi or configuring
>>> apache or what have you, to work with Catalyst, but before I take that
>>> on, my question is, is it likely that the slow loading of very small
>>> images has to do with the default myapp_server.pl, and switching to
>>> something else will make a big difference with loading images and
>>> possibly other files?
>> I don't recommend going live by running myapp_server.pl - this is
>> intended for development and debugging. I do recommend using a
>> standalone fastcgi process farm (which could have just a single
>> instance), talking through a named pipe in the /tmp directory. The
>> fastcgi process runs in your application user account, saving you from
>> having to open up the permissions of your files to the www-data user.
>> This is quite well documented, see
>> http://search.cpan.org/~mramberg/Catalyst-
>> Runtime/lib/Catalyst/Engine/FastCGI.pm
>> Also apart from in special circumstances, there's usually no reason to
>> serve images through your Catalyst application. The special
>> circumstances I imagine could be if the image is being stored in a
>> database blob, or being tweaked on the fly with ImageMagick.
>> One option could be to change the URLs for the images to be absolute
>> ones on the webserver, rather than static/images/powered_by.jpg etc.
>> which will deliver performance results with myapp_server.pl. You'd need
>> to copy the root/static/images directory to somewhere more public, where
>> the www-data user can see and use it. A recommended, documented option
>> is to configure Apache to handle /static rather than pass these requests
>> to the application with the following config snippet:
>> <Location /static>
>>             SetHandler          default-handler
>> </Location>
>> For more on configuring Apache 2.0, see
>> http://search.cpan.org/~agrundma/Catalyst-Engine-
>> Apache/lib/Catalyst/Engine/Apache2/MP20.pm
>> Please bear it in mind that most of the information in this Pod is about
>> configuring  your Catalyst app to run under mod_perl. I much prefer
>> fastcgi as it gives me much more control and awareness of machine
>> resources, keeps my permissions sane, and allows me to run multiple
>> different Catalyst applications and versions on the same box.
>> Ivor.
>> _______________________________________________
>> List: Catalyst at lists.scsys.co.uk
>> Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
>> Searchable archive: http://www.mail-
>> archive.com/catalyst at lists.scsys.co.uk/
>> Dev site: http://dev.catalyst.perl.org/
> _______________________________________________
> List: Catalyst at lists.scsys.co.uk
> Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
> Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
> Dev site: http://dev.catalyst.perl.org/

More information about the Catalyst mailing list