From: Robert Klemme Date: 2003-02-26T19:35:03+09:00 Subject: Re: Ruby in Performance Testing From what you write I conclude that the server creates a thread for each request. This might indicate a design problem in the server, because the overhead of creating threads is often significant. Typical server implementations use a thread pool with a fixed or at least limited amount of threads that handle all requests, which they receive from an event queue. Kind regards robert "E F van de Laar" schrieb im Newsbeitrag news:20030226082715.GA529@il.fontys.nl... > Rubyists, > > I'm trying to setup a performance/load test to bombard a server with > a ton of requests. The idea is to generate as many parallel requests > as possible to really stress the server. However my code already bombs > out at around 300 threads with: > > naft_s.rb:140: [BUG] rb_sys_fail() - errno == 0 > ruby 1.7.3 (2002-11-17) [i386-mswin32] > > I also get "Bad file descriptor" errors at times. > > Does anyone have any other approaches for this kind of test? Is ruby > not up to this sort of task? Would fork be a better approach? > How do I raise this limit? Any tips are welcome. > > The stripped code making 500 parallel requests; each in turn doing 10 > sequential requests. > > #!/usr/bin/ruby -w > > require 'socket' > require 'thread' > > threads = [] > > (1..500).each do |c| > threads << Thread.new(c) do |client| > (1..10).each do |request| > begin > TCPSocket::open('localhost', 80) { |s| > # perform some socket reading writing here > # and print some output > } > rescue Exception => e > $stderr.puts e > end > end > end > end > > threads.each { |t| > t.join > } > > Emiel > -- > E F van de Laar > +31648183479 > www.il.fontys.nl/~emiel >