<br><br><div class="gmail_quote">On Thu, Mar 5, 2009 at 4:15 PM, mike <span dir="ltr">&lt;<a href="mailto:mike503@gmail.com" target="_blank">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;">

I guess I would be more than happy then to stop using php-fpm and use<br>
this new tool.<br>
<br>
However I do like the benefits of php-fpm like the ability to override<br>
some php.ini directives.<br>
</blockquote><div><br>This seems like something that still appropriate for PHP&#39;s FCGI wrapper, even if that wrapper no longer needs to manage pools of processes.<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>
Perhaps we should get Grzegorz (fcgiwrap), Andrei (php-fpm) and others<br>
together for this.<br>
</blockquote><div><br>I&#39;d love to see if there&#39;s interest in this idea.<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>

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