| > while (my $req = CGI::Fast->new) { myApp->run($req); }
> Is there a handler/wrapper for that? Assuming that while loop is in your bootstrap FastCGI script, you can instead have an app.psgi (or whatever named) file with the content: use CGI::PSGI;
my $app = sub { my $req = CGI::PSGI->new(shift); myApp->run_psgi($req) };
Now your new `run_psgi()` method should return the [ $status, $headers, $body ] array reference, instead of printing them to the STDOUT. And then the app.psgi can be run from CGI, FastCGI, mod_perl, Starman, Twiggy or whatever PSGI supported web servers.For most web frameworks, the change should be minimal and straightforward: for example, CGI::Application needed less than 10 lines of code to implement this.
http://search.cpan.org/~markstos/CGI-Application-PSGI-1.00/ (I implemented the original code, and markstos, the maintainer of CGI.pm and CGIApp now took it over. As you can see there's a small hack to capture the output - they're working on removing this hack by implementing the PSGI natively inside the CGIApp codebase) > WebGUI discovered FastCGI via a PSGI implementation but it's FastCGI who brought the speed, No, they got a performance boost with our preforking standalone HTTP server, which is currently called Starman, not just FastCGI. Speaking of FastCGI, although Plack has a FCGI.pm-based FastCGI handler, i've been working on another FastCGI based preforking PSGI server called fastpass. https://github.com/miyagawa/fastpass It is XS dependency free (unlike FCGI.pm and CGI::Fast) and the performance is still the same with FCGI.pm, roughly like 4000 requests per second on my laptop, with a simple HelloWorld app via an nginx frontend. I guess we could do even better by doing optional XS parsing with pure perl fallback as well. FWIW for a comparison, with Starman I get 7k and Feersum gets 9k requests per second on the same machine. (Of course the number is not that significant since in the real world, your application does more IOs, templating stuff and database handling, and the qps would be much smaller) Again, the nice thing about all of these things is that your code, and everyone else's code, don't need any line of code change to support this new server, once you get PSGI. > In the meantime, I will try to play with it on my spare time. I guess it will be the easiest way to discover what I might be missing... I'm pretty sure you will :) |
Yes it is.
> For most web frameworks, the change should be minimal and straightforward
Indeed, it seems so.I'll try it out.
>No, they got a performance boost with our preforking standalone HTTP server,
I was talking about these lines in the article, where Starman is not used at all:
--------
I’ve codenamed the project “PlebGUI“, which I think aptly describes the way it makes it possible for the little people to run WebGUI on low-cost shared hosting.
And it actually works. Take for instance plebgui.patspam.com, a demo PlebGUI site site running in FastCGI mode on HostMonster (the prototypical low-cost shared webhost).
---------
Even though, the application did have even better performance via Starman but it is more a server matter than a PSGI related matter.
>fastpass [...] is XS dependency free (unlike FCGI.pm and CGI::Fast) and the performance is still the same with FCGI.pm, roughly like 4000 requests per second on my laptop, with a simple HelloWorld app via an nginx frontend. I guess we could do even better by doing optional XS parsing with pure perl fallback as well.
THIS is interesting.