3

What I know about the FCGI protocol is, the first time the application is called, it loads it into memory, run it, return the response to the server, finish the response but does not end the application, it keeps it running in memory, then next requests will use this compiled in memory copy of the application to process the request.

Reading about the PSGI protocol, it seems to be working the same way.

My question is, is my assumption correct, they are the same regarding the application speed to requests per second.

the confusing issue also if they work the same, why I see plackup has command line option to enable FCGI.

daliaessam
  • 1,636
  • 2
  • 21
  • 43

1 Answers1

10

You're asking for a comparison between apples and fruit. Your question doesn't make much sense.

There are various underlying mechanisms you can use to deploy a web application written in Perl.

  • It can be a standalone CGI program
  • It can run under mod_perl
  • It can run under FCGI
  • etc ...

The problem is that for each deployment mechanism you need to change the way that your program is written. This means that you need to know that you're, say, targetting mod_perl before you start writing the code. It also means that moving an application between these various deployment methods is non-trivial.

This is the problem that PSGI solves. Instead of writing a CGI app or a mod_perl app or a FCGI app, you write an app that targets the PSGI protocol. You can the deploy exactly the same app under CGI, mod_perl or FcGI (or many other deployment methods).

If you deploy your PSGI app using the FCGI handler, then it will work the same way as a FCGI app. But later on it's simple to move it to run as a mod_perl app. Or to run it as a standalone server using something like Starman.

Does that help at all?

Dave Cross
  • 68,119
  • 3
  • 51
  • 97
  • I know that PSGI has adaptors for cgi, fcgi, mod_perl, but you did not answer the question, what is the benefit from using psgi to run fcgi app under it, is not it better to run the fcgi app direct under the fcgi instead of the middle ware of psgi, your explanation says that the psgi only benefit is the same app can run under any of these protocols, this means that if I want to run the app under fcgi then no need to think about the psgi at all, am I correct? – daliaessam Jul 27 '14 at 16:29
  • 1
    @daliaessam you **didn't run** the _fcgi app_ under PSGI. You run your perl-app (what is written with PSGI) under _fgci_ or standalone perl-server and such. With PSGI you got an "standard" what allows many cool things, such using Plack::Middlewares a like. IMHO the easiest way run (develop and deploy too) any perl-web-app is using PSGI. – clt60 Jul 27 '14 at 18:28
  • 1
    Well, there are plenty of other advantages to writing your program to the PSGI spec. A huge ecosystem of middleware plugins, for a start. – Dave Cross Jul 27 '14 at 18:43
  • 1
    @daliaessam If you write to [PSGI](http://plackperl.org/) you don't have to modify your code if you change backends. This is why frameworks like [Catalyst](http://www.catalystframework.org/) and [Dancer](http://www.perldancer.org/) now target [PSGI](http://plackperl.org/). For them it means they don't have to maintain the code to target more than one backend ( which they used to do ). – Brad Gilbert Jul 28 '14 at 19:33