Perl in shared hosting environments

Tatsuhiko Miyagawa miyagawa at gmail.com
Fri Sep 23 01:18:52 BST 2011


On Wed, Sep 21, 2011 at 4:04 AM, Dirk Koopman <djk at tobit.co.uk> wrote:

>> Check out Plack:
>>
>> http://plackperl.org/   - https://metacpan.org/module/Plack
>>
>>
>> http://blog.plackperl.org/2011/08/plack-basics-for-perl-websites-yapceu-2011.html
>>
>> Then you can switch between mod_perl / FastCGI / Starman / Twiggy to your
>> hearts content (we found Starman is REALLY fast).
>
> I am happy to be educated, but I found Plack introduced a load of
> dependencies that I did not want,

Plack is the reference implementation of PSGI handlers and middleware,
and it only has a few dependencies that could potentially be already
dependent in most cases if you're doing a web development in perl
(such as URI and LWP), but that mileage might vary.

The nice thing about Plack/PSGI however is that you *decouple* your
application code from the runtime environment such as mod_perl and
FastCGI - you write your application to target the PSGI interface,
then your app will run on any environments that supports PSGI (via
Plack handlers) such as mod_perl, FastCGI, Starman etc. with
absolutely zero changes.

> it *is* another layer which cannot help
> but reduce speed - which may not matter - but did to me at the time.

Switching to Plack/PSGI actually gives better performance in many
cases, particularly because PSGI uses Perl's native data types such as
hash reference, array reference instead of objects with hundreds of
method calls. Wrapping the interface with a nice OO is the job of
framework, not PSGI. It does *not* get in the way.

For my simple (and naive) Hello World application testing, Starman,
Starlet and Feersum web servers got a better performance than CGI.pm
(with mp2 wrapper) + mod_perl, for example.

http://www.reddit.com/r/perl/comments/h6qqr/the_psgi_is_the_limit/ has
an amusing comment thread about the performance and benefit of PSGI
over existing wrappers like CGI.pm, started by "shi4" - you might need
to click the thread to collapse to read the whole thread.

>>
>> You also get a lot (160+ modules) of nice middleware available.
>>
>
> More software to, at least potentially, "get in the way" or add unnecessary
> dependencies or unwanted constraints.

PSGI interface and middleware works consistent as an interface between
the application and servers. It doesn't get in the way.


-- 
Tatsuhiko Miyagawa



More information about the london.pm mailing list