[Catalyst-dev] Re: Catalyst in windows environment

kmx kmx at volny.cz
Sat Jun 20 19:50:57 GMT 2009


Hi,
> Hi, good day. it looks like that there are plenty of good examples done on
> UNIX/Linux, I just wonder anybody can share some experience with
> Catalyst/Windows.
>   
According to my experience Catalyst works on Windows quite nice and is
stable enough even for production applications. However it is true that
the most of troubleshooting questions and answers you can find on the
Internet concern running Catalyst on UNIX (mostly Linux) platform.

> Our application is done with plain CGI/Apache/Windows/SQL Server and we want
> to explore the possibility to overhaul the architecture. My main question is
> when using windows server:
> FastCGI or Mod-Perl? which one works and works better? any potential
> problem?
>   
If you are thinking about running serious Catalyst application on a
Windows box go for FastCGI - do not waste time with mod_perl
experiments. Even UNIX guys are not sure about the efficiency of running
Catalyst application under mod_perl; the other thing is that mod_perl is
Apache specific so you cannot use for example MS IIS.

Here are some issues you are very likely to run into with Catalyst on
Windows:

(1) What perl to use?

You have basically 2 options: 1) Strawberry perl -
http://strawberryperl.com 2) ActiveState perl -
http://www.activestate.com. I would recommend strawberry perl as it
supports CPAN and you can install required modules directly form there
(if you are not familiar with catalyst at the moment you will be
probably surprised how many modules Catalyst directly or indirectly
requires in its dependencies - so "cpan" command is definitely gonna
become your friend :)

After some time I have come into conclusion that for production use it
is definitely better to use perl version 5.8.9 as currently available
5.10.0 is not so stable on Win32 and have some serious bugs. For example
this one is my favourite - "broken fork":
c:\> perl -e "use namespace::clean; my $p=fork;"
this command causes perl 5.10.0 @ Win32 to crash during fork call (both
Strawberry and ActiveState) - BTW this was the reason (or at least one
of) why fork-based Catalyst::Restarter did not work well on Win32 and
was reimplemented using Proc::Background.

It is good to mention that some modules have problems with installation
via "cpan" command - namely HTTP::Server::Simple WWW::Mechanize
Class::Throwable do not pass tests (fortunately the problem is just
purely written tests; the modules works fine on Win32). Another issue is
with Catalyst::Devel and its disordered dependencies (you have to
install manually Win32::Process before Catalyst::Devel).

To sum up my recommendation:
1) download and install
http://strawberry-perl.googlecode.com/files/strawberry-perl-5.8.9.1.exe
2) from commandline run following commands
set PERL_MM_USE_DEFAULT=1
perl -MCPAN -e "notest('install', 'HTTP::Server::Simple',
'WWW::Mechanize', 'Class::Throwable');"
cpan Win32::Process Catalyst::Runtime Catalyst::Devel

(2) What webserver to use?

As mentioned before for a serious (production) application in my opinion
you have to use FastCGI. On Win32 I can recommend either Apache+FastCGI
or IIS+FastCGI. The things are however little bit tricky.

Microsoft IIS
- Catalyst works fine just with IIS6 (Windows 2003) and IIS7 (Windows
2008/Vista)
- for running on IIS7 you need currently latest Catalyst::Runtime 5.80005
- IIS5.0 (Windows 2000) and IIS5.1 (Windows XP) do support FastCGI
however not enough to run Catalyst applications
- more info you can find at
http://search.cpan.org/~mramberg/Catalyst-Runtime/lib/Catalyst/Engine/FastCGI.pm#Microsoft_IIS

Apache @ Win32
- on Windows 2000 / XP is Apache in fact the only option for running
production Catalyst application
- you might know that Apache has two modules (competitors) for FastCGI
support - mod_fastcgi and mod_fcgid
- after quite a long research I managed to run Catalyst application just
via mod_fastcgi, mod_fcgid did not work for me
- to be specific my working combination: Apache 2.2.11 + mod_fastcgi
SNAP-0811090952 (latest stable v2.4.6 does not work well on Win32)
- if you want I can put somewhere more detailed instructions and sample
configuration

My recommendation is: with Catalyst application on Win32 go with MS IIS
if you can. In theory you have also some other options like nginx for
Win32 or using Catalyst::Engine::HTTP::Prefork but those are not my
favourites.

(3) Threads - something that UNIX guys do not need to deal with

When running Catalyst application (this is not specific to Catalyst) on
Win32 it is good to know that  you might run into troubles with modules
that are not thread-safe as FastCGI processes on Win23 are in fact
threads and the whole Catalyst application can behave slightly
differently than on UNIX platform. Currently I know of just one module
quite frequently used in Catalyst applications that is not thread-safe -
it is Cache::FastMmap; thus all Catalyst modules based on it (e.g.
Catalyst::Plugin::Session::Store::FastMmap) have the same problem and it
is better not to use them on Win32.

Concerning threads it is also good to keep in mind that on Win32
platform the perl call "fork" is implemented as an emulation via threads
- so even using the "fork" in your perl program/package leads into
thread-safe/unsafe problems.

--
kmx



More information about the Catalyst-dev mailing list