<br><br><div class="gmail_quote">On Thu, Mar 5, 2009 at 9:56 AM, mike <span dir="ltr">&lt;<a href="mailto:mike503@gmail.com">mike503@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Sure - you mean anything that nginx (or any other server) speaks fastcgi to<br>
</blockquote><div><br>Yes!<br> </div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><br>
webserver &lt;-&gt; this process manager &lt;-&gt; code (perl cgi, or anything else) ?<br>
<br>
Wouldn&#39;t this also be able to replace php-fpm then?<br>
</blockquote><div><br>Ideally, yes.  Even with PHP&#39;s unique lifecycle (all objects discarded after each request), I don&#39;t see a reason why process pool management needs to be built in to PHP FastCGI handling.  Each PHP process could manage the request lifecycle for itself while the process pool management could be handled generically, just like any other language.<br>
 </div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><br>
It seems like there are already ways using Tomcat/etc. for java,<br>
php-fpm for PHP, ruby and python have managers, but CGI does not. Can<br>
you give an example of what other things you&#39;d want this to manage?</blockquote><div><br>In short, I&#39;d be happy if it exactly matched the process management features of mod_fastcgi for Apache.  mod_fastcgi does both FastCGI proxying and process management.  Nginx + other event driven webservers implement the FastCGI proxying piece but not the process management piece.<br>
<br>You&#39;re right that each language seems to have a different way of managing processes.  This is appealing when all the infrastructure you run is in a single language.  If you run ruby, you do it &quot;the ruby way&quot;.  However, the organizations I&#39;ve worked for need to run code in different languages, for various reasons including aquisition or migration.  I think everyone would benefit from a language agnostic process manage similar to mod_fastcgi but not tied to Apache.<br>
 </div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><br>
<div><div></div><div class="h5"><br>
On Thu, Mar 5, 2009 at 9:22 AM, Roger Hoover &lt;<a href="mailto:roger.hoover@gmail.com">roger.hoover@gmail.com</a>&gt; wrote:<br>
&gt; This is an interesting idea.  I&#39;d like to see a generic process manager come<br>
&gt; out of the effort though, not just one that only works for wrapping CGI.  It<br>
&gt; would be a great separation of concerns.   The CGI wrapper could focus on a<br>
&gt; single task: accepting FastCGI requests and forking CGI processes to handle<br>
&gt; them.  Process pool management could be handled by a generic FastCGI process<br>
&gt; manager, which could manage fcgiwrap pools and any other type of FastCGI<br>
&gt; processes.<br>
&gt;<br>
&gt; On Wed, Mar 4, 2009 at 9:05 PM, mike &lt;<a href="mailto:mike503@gmail.com">mike503@gmail.com</a>&gt; wrote:<br>
&gt;&gt;<br>
&gt;&gt; I am going to start a cgi-fpm project. The goals will be aligned like<br>
&gt;&gt; php-fpm except slightly modified for the differences with cgi and fastcgi.<br>
&gt;&gt; It might not be able to support adaptive spawning without some sort of api<br>
&gt;&gt; or tools but at least will make management easier and not require third<br>
&gt;&gt; party tools. It will basically enhance fcgiwrap with php-fpm style<br>
&gt;&gt; configuration and hooks for external control for things like an nginx<br>
&gt;&gt; module.<br>
&gt;&gt;<br>
&gt;&gt; The annoyances with cgi and fastcgi can be discussed and hopefully<br>
&gt;&gt; addressed.<br>
&gt;&gt; Thoughts?<br>
&gt;&gt; Also this could just be an nginx module too. But it would add some weight<br>
&gt;&gt; and require suexec type stuff. So probably not a good idea.<br>
&gt;&gt; Let me throw together a quick list of ideas.<br>
&gt;&gt; On Mar 4, 2009, at 12:34 PM, Roger Hoover &lt;<a href="mailto:roger.hoover@gmail.com">roger.hoover@gmail.com</a>&gt; wrote:<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; On Wed, Mar 4, 2009 at 11:51 AM, mike &lt;<a href="mailto:mike503@gmail.com">mike503@gmail.com</a>&gt; wrote:<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; On Wed, Mar 4, 2009 at 9:03 AM, Roger Hoover &lt;<a href="mailto:roger.hoover@gmail.com">roger.hoover@gmail.com</a>&gt;<br>
&gt;&gt;&gt; wrote:<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; &gt;&gt;  - dynamic pool size management (keep 1-5 running depending on load;<br>
&gt;&gt;&gt; &gt;&gt;   this will require congestion notifications from the web server, like<br>
&gt;&gt;&gt; &gt;&gt;   you said)<br>
&gt;&gt;&gt; &gt;<br>
&gt;&gt;&gt; &gt; Functionality was recently added to supervisord to modify it&#39;s<br>
&gt;&gt;&gt; &gt; configuration<br>
&gt;&gt;&gt; &gt; dynamically through the XML-RPC api so this is matter of implementing<br>
&gt;&gt;&gt; &gt; the<br>
&gt;&gt;&gt; &gt; load logic in an nginx plugin and making calls to supervisord to add<br>
&gt;&gt;&gt; &gt; and<br>
&gt;&gt;&gt; &gt; subtract from the pool.<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; While I would like to keep my software stack low, this sounds like a<br>
&gt;&gt;&gt; neat benefit. Would just need to define hard upper limits, and how<br>
&gt;&gt;&gt; long to wait or whatever to kill spare/unused children (like apache, I<br>
&gt;&gt;&gt; suppose)<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; Personally I would like to see a daemon that does this in itself.<br>
&gt;&gt;&gt; Leverages the fcgiwrap code + adds on features. I suppose it would<br>
&gt;&gt;&gt; have to be &#39;aware&#39; of how many connections it was servicing per pool<br>
&gt;&gt;&gt; which Grzegorz makes it sound like can be very hard... but then it<br>
&gt;&gt;&gt; could manage things dynamically.<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; request comes in -&gt; depending on what port/socket/etc. it checks the<br>
&gt;&gt;&gt; pool, determines if any children are open (if more needed, spawn like<br>
&gt;&gt;&gt; apache, maybe log a notice in the log), changes to proper uid/gid if<br>
&gt;&gt;&gt; configured, then executes the fastcgi stuff, if it gets back an error,<br>
&gt;&gt;&gt; determine whether or not to log it, pass it back with the same http<br>
&gt;&gt;&gt; code, do both, etc..<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; etc.<br>
&gt;&gt;<br>
&gt;&gt; The approach you describe assumes that the parent process can intercept<br>
&gt;&gt; socket connections as they come in.  I don&#39;t think this is possible within<br>
&gt;&gt; the constraints of the FastCGI spec.  Each FastCGI process is forked with<br>
&gt;&gt; file descriptor 0 pointing to a shared FastCGI socket and each child process<br>
&gt;&gt; just calls accept() on that socket.  The OS is responsible to determining<br>
&gt;&gt; which process in the pool accepts each request so there&#39;s no way for the<br>
&gt;&gt; parent process to keep track of which child is taking which request.  Unless<br>
&gt;&gt; that information can be retrieved from the kernel, I think the only place<br>
&gt;&gt; that load logic can be implemented is in an nginx module.<br>
&gt;&gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; I don&#39;t understand enough about sockets, C, threading/forking/event<br>
&gt;&gt;&gt; models/etc. to see if that is even an option but it seems like it<br>
&gt;&gt;&gt; could be done, just not sure if it would be way too slow or not?<br>
&gt;&gt;&gt;<br>
&gt;&gt;<br>
&gt;<br>
&gt;<br>
<br>
</div></div></blockquote></div><br>