Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I need to serve some FCGI scripts (via WSAPI, but that is irrelevant) from nginx.

Currently I'm using spawn_fcgi to do this. This is the only solution I've found.

I need to know my other options. Are there any other ways to run FastCGI under nginx?

share|improve this question

4 Answers 4

up vote 5 down vote accepted

I personally prefer to decouple my FCGI processes from the webserver as much as possible, and manage them as I would any other daemon. In my case, I've switched all of that sort of thing to use daemontools, because it's small, lightweight, is very reliable, and does exactly what you need in this instance, with no mess or fuss.

share|improve this answer
    
Thanks for daemontools! I had re-invented the wheel twice, and you've just pointed me at the solution :) –  kolypto Nov 7 '09 at 0:16
    
Interesting solution, thanks. Have you compared performance with other solutions? –  Alexander Gladysh Nov 7 '09 at 11:04
1  
There's no performance difference, because the actual operation of the FCGI process is the same. Increased performance comes from multiple FCGI listeners load-balanced in the frontend, or else one FCIG listener that delegates requests to multiple threads or child processes. This is out of scope for a discussion of the launcher, though. –  womble Nov 7 '09 at 12:07
    
Out of scope, indeed. But I want to read up on the subject. Do you have a link? (I'll create a new question if needed.) –  Alexander Gladysh Nov 7 '09 at 17:57
    
Definitely worth a new question. –  womble Nov 7 '09 at 23:39

Yet again nobody mentioned php-fpm. It's now bundled with php itself so you should read docs about php-fpm in PHP manual.

share|improve this answer
    
Yeah, php-fpm is great FastCGI process manager. –  Valery Viktorovsky Feb 7 '10 at 9:35
    
for PHP, it is the best way to execute the zend engine. –  TechZilla Nov 26 '11 at 6:11

Potentially there's cgi-fcgi. What don't you like about the current method you're using?

share|improve this answer
    
Not that I don't like something specific... I have not enough data for that (yet). I've just overheard some vague and unspecific negative opinions about spawn_fcgi. I'm trying to find out what else I can use just in case. –  Alexander Gladysh Nov 6 '09 at 22:57
    
Note that I'm talking about high load (up to C10K) situation. –  Alexander Gladysh Nov 6 '09 at 22:58

Theoretically, there are 3 options how PHP can be attached to nginx:

  1. Module. Currently, there's no nginx PHP module. Minus.
  2. CGI. PHP is spawned at every request, and a single php process parses a single php file. execve() overhead is obvious. Dirty Plus.
  3. FCGI. Pre-spawned processes which handle requests, and never stop. Plus.

There's 2 methods of creating these FCGI processes:

  1. Pre-launch them. That's what spawn_fcgi does, and that is okay.
  2. Let nginx launch them: nginx tries to connect to localhost:, and if there's nobody listening, spawns php FCGI workers. That would have been better in terms of administration comfort and stability, but I've never heard of such a module for nginx :) Maybe, you'll be the first one to develop it? ;)

spawn script is not evil, really :)

P.S. Походу, самый пытливый ум у русских ;)

share|improve this answer
    
That does not matter, of course, but I do not use PHP (but do use Lua, via WSAPI). –  Alexander Gladysh Nov 6 '09 at 23:46
    
Regarding auto-launching of FCGI processes by nginx. Can you please elaborate? Perhaps you have a link to a similar system description for another web-server? –  Alexander Gladysh Nov 6 '09 at 23:48
    
No, the idea just came out of my head while I was writing this reply :) I've heard nothing of auto-spawning FCGI in nginx, nor with other httpd-s –  kolypto Nov 7 '09 at 0:13
    
Lighttpd does auto-spawning, and it's as bad an idea as it sounds. –  womble Nov 7 '09 at 4:56

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.