URIS http://codeforpeople.com/lib/ruby/acgi/ SYNOPSIS as·sid·u·ous (adj.) 1. constant in application or attention; diligent: an assiduous worker who strove for perfection. 2. unceasing; persistent: assiduous research. acgi : assiduous or ara's cgi (emphasis on the 'ass' in assiduous) a drop-in replacement for ruby's built-in cgi that provides copious features such as - no apache modules - persistence - speed - simplicity - familiarity - no apache modules - browser neutrality - could easily be made platform independent - no apache modules - no special webserver setup or system privledges required - ability to install to a webserver via ftp - no apache modules - session affinity, all request handled by one process - automatic reload if code changes - ability to run script simulaneously as acgi and cgi for debuggging - ability to easily start/stop/restart/check-on running server - 178 lines of ruby code (and one c program) - no apache modules PERFORMANCE case one, a simple cgi that just dumps the environment: with acgi: [ahoward@localhost acgi-0.1.0]$ ab -n100 -c4 http://localhost/acgi/acgi-0.1.0/ | grep 'Requests per second' Requests per second: 74.93 [#/sec] (mean) without: [ahoward@localhost acgi-0.1.0]$ ab -n100 -c4 http://localhost/acgi/acgi-0.1.0/server.cgi | grep 'Requests per second' Requests per second: 18.76 [#/sec] (mean) a more realistic cgi that uses sessions and sleeps for 1 second to mimic connecting to a database: with acgi: [ahoward@localhost acgi-0.1.0]$ ab -n100 -c4 http://localhost/acgi/acgi-0.1.0/ | grep 'Requests per second' Requests per second: 24.20 [#/sec] (mean) without: [ahoward@localhost acgi-0.1.0]$ ab -n100 -c4 http://localhost/acgi/acgi-0.1.0/server.cgi | grep 'Requests per second' Requests per second: 3.63 [#/sec] (mean) ARCHITECHTURE the design of acgi is similar to that of fastcgi (http://www.fastcgi.com) but requires no external modules, configuration of apache, etc. a acgi application consists of a cgi server backend which loops, handling all incoming requests; the requests are delegated to this backend server via a simple, fast to start up, 'index.cgi' program written in c. communication between 'index.cgi' and it's backend server is via named pipes (fifos): ------------- | index.cgi | <- transient compiled c code ------------- | | | | fifos for stderr, stdout, stdin, env | | | / | \ ------------------------------ | | | cgi server | <- persistent looping ruby code | | ------------------------------ note that the architechture is similar in spirit to fastcgi - it provides speed by avoiding startup overhead and redundant work like database connection setup. in this case, contrasted with fastcgi, the whole thing takes place outside of the webserver in the applica