lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

On 23 Oct 2009, at 8:25 PM, Bertrand Mansion wrote:

I'd be interested in seeing how you start spawn-fcgid with wsapi-fcgi,

Sure; this is by no means a complete example, but it's most of what's relevant. Note that there's two files with the name wsapi.fcgi, typically (using luarocks) you'd spawn with the shell script in lib/ bin or thereabouts. In my setup I actually pass launch arguments via wsapi.fcgi, through the wsapi_env to the webapp so that each server [process] knows which it is (most folks probably wouldn't need this), and thus I use a modified version of the Lua script of the same name (having «function wsapi_loader»).

It seems best (and makes sense) to have as many fastcgi servers as you have CPU cores (of course shared memory/data access may then become an issue). In my usage under Ubuntu, no single fastcgi server seems capable of using more than 30% of a core (and webserver 40-50% of a core), and adding additional servers doesn't make better use of the CPU...

-- spawn-fcgi

spawn-fcgi -s /tmp/1.fcgi.socket -- wsapi.fcgi &
spawn-fcgi -s /tmp/2.fcgi.socket -- wsapi.fcgi &

-- nginx

http {
 upstream wsapi {
       server unix:/tmp/1.fcgi.socket;
       server unix:/tmp/2.fcgi.socket; }
 server {
	location /static/ {
		root /var/www; }
       location /favicon.ico {
		alias /var/www/static/favicon.ico; }
	location / {
           	fastcgi_pass wsapi;
           	include fastcgi_params; }

-- lighttpd

server.modules += ( "mod_rewrite" )
url.rewrite-once = (
	"^/robots.txt" => "/static/robots.txt",
	"^/favicon.ico" => "/static/favicon.ico",
	"^/static/(.*)$" => "/static/$1",
	"^/(.*)" => "/wsapi.fcgi/$1",
server.modules += ( "mod_fastcgi" )
fastcgi.server = ( "/wsapi.fcgi" => (
 (	"socket" => "/tmp/1.fcgi.socket",
	"check-local" => "disable" ),
 (	"socket" => "/tmp/2.fcgi.socket",
	"check-local" => "disable" ),

If you use bin-path and max-procs for each fastcgi server you can achieve better load handling, however this is being depreciated (and makes it impossible to pass launch args).