<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Sat, Feb 14, 2015 at 2:12 PM, silvioprog <span dir="ltr"><<a href="mailto:silvioprog@gmail.com" target="_blank">silvioprog@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Sat, Feb 14, 2015 at 3:18 AM, silvioprog <span dir="ltr"><<a href="mailto:silvioprog@gmail.com" target="_blank">silvioprog@gmail.com</a>></span> wrote:</div><div class="gmail_quote">[...] <blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"> I came up with a question: how can I configure the FastCGI to accept more than one request per connection? Is it possible in proxy mode?! ...</div></div></div></blockquote></div><div><br></div><div>I'm using Apache24 to debug the draft app, and today I've seen the following information on Apache documentation:</div><div><br></div><div>===</div><div><p style="line-height:1.3em;margin:0px 0px 1em;padding:0px;color:rgb(0,51,102);font-family:Arial,Helvetica,sans-serif;font-size:14px"><code style="font-family:'Courier New',Courier,monospace;font-size:1em;color:rgb(139,69,19);background-color:inherit"><a href="http://httpd.apache.org/docs/trunk/mod/mod_proxy_fcgi.html" style="color:rgb(188,143,143);background-color:inherit" target="_blank">mod_proxy_fcgi</a></code> disables connection reuse by default, so after a request has been completed the connection will NOT be held open by that httpd child process and won't be reused. If the FastCGI application is able to handle concurrent connections from httpd, you can opt-in to connection reuse as shown in the following example:</p><div style="color:rgb(0,0,0);padding:0.5em;margin:1em 2em 1em 1em;font-family:Arial,Helvetica,sans-serif;font-size:14px;background-color:rgb(229,236,243)"><h3 style="color:rgb(0,51,102);font-size:14px;margin:0px 0px 0.5em;padding:0px;background-color:inherit">Single application instance, connection reuse</h3><pre style="font-family:'Courier New',Courier,monospace;margin-top:0px;margin-bottom:0px;padding:0px;border:none;font-size:13px"><span style="color:rgb(17,34,136);font-weight:bold">ProxyPass</span><span> </span><span style="color:rgb(102,102,0)">/</span><span>myapp</span><span style="color:rgb(102,102,0)">/</span><span> fcgi</span><span style="color:rgb(102,102,0)">://</span><span>localhost</span><span style="color:rgb(102,102,0)">:</span><span style="color:rgb(0,119,119)">4000</span><span style="color:rgb(102,102,0)">/</span><span> enablereuse</span><span style="color:rgb(102,102,0)">=</span><span>on</span></pre></div></div><div>Source: <a href="http://httpd.apache.org/docs/trunk/mod/mod_proxy_fcgi.html" target="_blank">http://httpd.apache.org/docs/trunk/mod/mod_proxy_fcgi.html</a>.</div><div>===</div><div><br></div><div>I downloaded the httpd-2.4.12-win64-VC11.zip package, now I'm going to debug my app using this option ...</div></div></div></blockquote></div><div><br></div><div>I was able to make the example works in "enablereuse=on" mode! =)<br></div><div><br></div><div>It was not necessary to change the mycustfcgi.pas, it is the same as the previous example.</div><div><br></div><div>This made the application more responsive, now I hold the F5 key on the browser and I can see the millisecond changing on the screen, even with another tab "locked" in a 10-second loop. In the first example it was not possible.<br></div><div><br></div><div>In that second example was added the "KeepConnection" property. If it is False, the application will work as the first example that I sent: each connection is closed in the end of request. If it is True, it will only open a new thread if the first thread was still occupied in any processing, otherwise the AcceptConnection of the application will be used.</div><div><br></div><div>I'm really impressed with the great performance achieved, please check this log below (Chrome debug the result):<br></div><div><br></div><div>KeepConnection = False<br></div><div>--</div><div><br></div><div><div><b>Status 200 OK - Loading time: 1022 ms</b></div><div><br></div><div>KeepConnection = True<br></div><div>--</div><div><br></div><div><b>Status 200 OK - Loading time: 8 ms</b></div></div><div><br></div><div>To test it, download the attached example, unzip and run it. Using Apache 2.4.12+, make the following change in your httpd.conf:<br></div><div><br></div><div>LoadModule proxy_module modules/mod_proxy.so<br></div><div>ProxyPass /test fcgi://localhost:8080/ enablereuse=on<br></div><div>LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so</div><div><br></div><div>PS: in the code there is the comment "we will in Place the thread pool here ...", showing that at that point we will implement the thread pool, with a thread-safe list.<br></div><div><br></div>--<br><div class="gmail_signature">Silvio Clécio<br>My public projects - <a href="http://github.com/silvioprog" target="_blank">github.com/silvioprog</a></div>
</div></div>