Tuesday, April 01, 2008

Rack :: A Ruby Webserver Interface

Over on the Ruby-lang list, there was a discussion which pointed me to Rack. Check it out:

Rack provides an minimal interface between webservers supporting Ruby and Ruby frameworks.
  • super simple API for writing web apps
  • single API to connect to mongrel, fast-cgi, webrick
  • based on python’s WSGI, which was a good thing for python

Found this intriguing...
  • using the mongrel handler we can get crazy concurrency
  • let’s have a look at this, using ab
    • %w(rubygems rack).each { |dep| require dep }
      app = lambda { |env| sleep(5); [200, {}, 'Oi!'] }
      Rack::Handler::Mongrel.run(app, :Port => 3000)
    • ab -c 100 -n 300
    • Benchmarking (be patient)
      Completed 100 requests
      Completed 200 requests
      Finished 300 requests
      Concurrency Level: 100
      Time taken for tests: 15.232 seconds
      Complete requests: 300
      Failed requests: 0




No comments: