Best practices for running Perl?
mdounin at mdounin.ru
Fri May 1 00:09:09 MSD 2009
On Thu, Apr 30, 2009 at 11:46:47AM -0700, Mark Aiken wrote:
> My apologies for the newbie question; I have poked around quite a bit
> and can't find a definitive answer.
> I'm planning to use nginx to set up a lightweight server on a slim
> virtual-slice host where resources are at a premium. The server will
> mainly just relay data from clients to back-end systems, so I don't
> need a fancy render layer or persistence model. I'm planning to go
> with Perl for its stability and light footprint.
> My question is, what is the current best-practice for running Perl
> behind nginx? Is the built-in Perl module stable enough to consider
> using in production or should I stick with a hand-rolled FCGI wrapper?
Embedded perl in nginx is NOT for general purpose programming. It
runs in nginx worker processes and it MUST NOT block (or all your
connections in the same nginx worker will be blocked as well) -
and this generally means you can't use DBI, anything that resolves
hostnames and so on.
It was designed to do small things that can't be easily done with
nginx itself - e.g. map some variable to another complex one -
and it does this well enough. But don't try to use it for general
purpose web programming.
Use either fastcgi or http backends if you need something general.
> If someone feels that there would be a better slim-language choice
> that is better supported by nginx instead of Perl, I would appreciate
> hearing about that as an alternative.
More information about the nginx