{"id":155,"date":"2007-10-12T19:43:00","date_gmt":"2007-10-12T19:43:00","guid":{"rendered":"http:\/\/blog.trungson.com\/?p=155"},"modified":"2007-10-12T19:43:00","modified_gmt":"2007-10-12T19:43:00","slug":"load-balancing-fastcgi","status":"publish","type":"post","link":"http:\/\/blog.trungson.com\/?p=155","title":{"rendered":"Load balancing FastCGI"},"content":{"rendered":"<p>Run this command on a worker<\/p>\n<pre>spawn-fcgi -p 8081 -a 192.168.2.100 -f \/usr\/bin\/php-cgi -u lighttpd -g lighttpd -C 5 -P \/var\/run\/spawn-fcgi-8081.pid<\/pre>\n<p>Don&#8217;t forget to open up the right port (8081 in the example) and monitor the processes (say restart when it dies)<\/p>\n<h4>Reference<\/h4>\n<p>http:\/\/www.cyberciti.biz\/tips\/lighttpd-mod_proxy-to-run-php-fastcgi-app-server.html<\/p>\n<h4>Bind to a socket<\/h4>\n<p>spawn-fcgi -s \/tmp\/php-fastcgi-ext.sock -f \/usr\/bin\/php-cgi -u lighttpd -g lighttpd -C 5 -P \/var\/run\/spawn-fcgi.pid<\/p>\n<h4>Bind to an IP:port<\/h4>\n<p>spawn-fcgi -p 8081 -a 192.168.2.100 -f \/usr\/bin\/php-cgi -u lighttpd -g lighttpd -C 5 -P \/var\/run\/spawn-fcgi-8081.pid<\/p>\n<h4>Reference<\/h4>\n<p>http:\/\/trac.lighttpd.net\/trac\/wiki\/Docs%3AModFastCGI#load-balancing<\/p>\n<p>Need also to turn on lighttpd (service lighttpd start) so reporter can get status on this server directly (through port 80)<\/p>\n<h4>Using an external fcgi in lighttpd.conf to load balance only a specific file<\/h4>\n<pre>\nfastcgi.server = (\n\"\/index.php\"=>\n(\n (\"socket\"=>\"\/tmp\/php-fastcgi.socket\",\n  \"bin-path\"=>\"\/usr\/bin\/php-cgi\",\n  \"min-procs\"=>2,\n  \"max-procs\"=>4,\n  \"bin-environment\"=>(\"PHP_FCGI_CHILDREN\"=>\"10\",\"PHP_FCGI_MAX_REQUESTS\"=>\"5000\")\n ),\n (\"host\"=>\"192.168.2.100\",\n  \"port\"=>8081,\n  \"check-local\"=>\"disable\",\n  \"disable-time\"=>30\n )\n),\n\".php\"=>\n(\n (\"socket\"=>\"\/tmp\/php-fastcgi.socket\",\n  \"bin-path\"=>\"\/usr\/bin\/php-cgi\",\n  \"min-procs\"=>1,\n  \"max-procs\"=>2,\n  \"bin-environment\"=>(\"PHP_FCGI_CHILDREN\"=>\"5\",\"PHP_FCGI_MAX_REQUESTS\"=>\"1000\")\n )\n)\n)\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Run this command on a worker spawn-fcgi -p 8081 -a 192.168.2.100 -f \/usr\/bin\/php-cgi -u lighttpd -g lighttpd -C 5 -P \/var\/run\/spawn-fcgi-8081.pid Don&#8217;t forget to open up the right port (8081 in the example) and monitor the processes (say restart when it dies) Reference http:\/\/www.cyberciti.biz\/tips\/lighttpd-mod_proxy-to-run-php-fastcgi-app-server.html Bind to a socket spawn-fcgi -s \/tmp\/php-fastcgi-ext.sock -f \/usr\/bin\/php-cgi -u lighttpd [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9],"tags":[],"_links":{"self":[{"href":"http:\/\/blog.trungson.com\/index.php?rest_route=\/wp\/v2\/posts\/155"}],"collection":[{"href":"http:\/\/blog.trungson.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/blog.trungson.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/blog.trungson.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/blog.trungson.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=155"}],"version-history":[{"count":0,"href":"http:\/\/blog.trungson.com\/index.php?rest_route=\/wp\/v2\/posts\/155\/revisions"}],"wp:attachment":[{"href":"http:\/\/blog.trungson.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=155"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/blog.trungson.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=155"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/blog.trungson.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=155"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}