From: Sascha Ebach Date: 2004-05-27T20:42:00+09:00 Subject: Re: WEBrick and FastCGI response Hi Jim, Jim Freeze wrote: > Reply-To: > Name: Jim Freeze > Phone: (859) 396-5439 > Web-Pages: http://www.freeze.org http://www.freebsdportal.com > > I have been playing with webrick and fastcgi. I used ab > to measure the performance and see if fastcgi was helping out. > My results are: > > test.cgi - webrick & fastcgi > Concurrency Level: 1 > Time taken for tests: 44.546 seconds > Complete requests: 100 > Requests per second: 2.24 [#/sec] (mean) > Time per request: 445.46 [ms] (mean) > > test.rthml - webrick & fastcgi > Concurrency Level: 1 > Time taken for tests: 10.200 seconds > Complete requests: 100 > Requests per second: 9.80 [#/sec] (mean) > Time per request: 102.00 [ms] (mean) > > test.cgi - webrick w/o fastcgi > oncurrency Level: 1 > Time taken for tests: 43.583 seconds > Complete requests: 100 > Requests per second: 2.29 [#/sec] (mean) > Time per request: 435.83 [ms] (mean) > > test.rhtml - webrick w/o fastcgi > Concurrency Level: 1 > Time taken for tests: 10.221 seconds > Complete requests: 100 > Requests per second: 9.78 [#/sec] (mean) > Time per request: 102.21 [ms] (mean) > > I used the standard HTTPServer and only changed between > the following require lines to use webrick with and without > the server > > require 'webrick' # w/o fastcgi > #require 'webrick/fcgi'a # w/ fastcgi > > Am I using fcgi correctly or is it just not having an affect > for these samples? I tried the same thing. Came to the same conclusion. I tried emailing Ari, but haven't got any response. I am also not sure if I use it correctly. I would like to know a way how I can query if I am actually using the c fastcgi version. Here is what I wanted to send to the list a couple of weeks ago, but never did. Something else came up and I am not sure I even finished the mail. Nevertheless here it is: ----------- Hi folks, I have tried to contact Ari (the maintainer of webrick-fcgi) with this, but he still hasn't answered in a couple of days. Maybe he is not able to at the moment. My questions are better asked on the list anyway. I am trying to get webrick-fcgi to work on the Cygwin platform. What I am not really sure about, is how to find out if it really works the way it should and how to configure it properly. ### fcgi.rb require 'fcgi' require 'webrick/fcgi' include WEBrick dir = File::dirname(File::expand_path(__FILE__)) + '/test' puts dir s = WEBrick::HTTPServer.new( :BindAddress => "0.0.0.0", :Port => 8088, :DocumentRoot => dir, :Logger => WEBrick::Log::new($stderr, WEBrick::Log::DEBUG), :CGIPathEnv => ENV['PATH'] # Especially for Cygwin ) ## mount subdirectories trap("INT"){ s.shutdown } s.start ### my test script for cgi/fcgi (from rubygarden) ### test.cgi and test.fcgi #!/usr/bin/env ruby require 'cgi' require 'fcgi' FCGI.each_cgi do |cgi| content = '' env = [] cgi.env_table.each do |k,v| env << [k,v] end env.sort! env.each do |k,v| content << %Q(#{k} => #{v}
\n) end cgi.out{content} end ### when I access this script with http://localhost:8088/test.cgi I get the output, but when I access http://localhost:8088/test.fcgi I am asked if I want to download the file. How can I get the fcgi file to execute properly or better yet make custom mappings (*.rb files get executed by fcgi). Benchmarking gives me: $ /usr/sbin/ab http://localhost:8088/test.cgi | grep Request Requests per second: 3.21 [#/sec] (mean) this probably means that fcgi is never invoked cause my computer AMD 2600+ should be a little faster. ------------------ Maybe someone can explain how this module is used correctly? Thanks Sascha