From: Zev Blut Date: 2004-05-12T16:39:32+09:00 Subject: Pure Ruby FastCGI performance bug? Hello, I have noticed that, when using the pure Ruby implementation of FastCGI, sending a response over 8K causes long delays before the last chunk of data is sent. The C version does not cause any delay. At the end of this message is a sample program to show the issue. If you run the program a few times, usually after the second time, you may see that around the last 8K of data takes a long time to be sent. For example, a response of 100K takes about 30 seconds on my machine when call the fcgi via localhost. I am able to reproduce this with various RedHat Linux versions using mod_fastcgi, Apache 1.3 or 2.0, and Ruby 1.8.1 or 1.6.8. I thought some of you might want to know about this and if it is reproducible elsewhere. Best, Zev Blut ---- #!/usr/local/bin/ruby1.8 FCGI_PURE_RUBY = true # Comment out if you want to test with c version require 'fcgi' RANDOM_CHAR = (("A".."Z").to_a + ("a".."z").to_a + ("0".."9").to_a).to_s SIZE = 1024 * 100 def random_char() rnd = rand(RANDOM_CHAR.size) RANDOM_CHAR[rnd..rnd] end # Generate the data string once, to avoid computation during request. data = "" SIZE.times do |i| data<< random_char end FCGI.each do |request| request.out.print "Content-Type: text/plain\r\n" request.out.print "Content-Length: #{data.size}\r\n" request.out.print "\r\n" request.out.print data request.finish end