Rails now generally running on Ruby 1.9.0
Amid all the RailsConf hype about Rails 2.1.0 and Maglev, not much attention seems to have been given to the fact that Rails is now generally, mostly runnable on Ruby 1.9.0.

Here’s the Ruby-Core message confirming the news. Not all tests are currently passing - almost all of them related to the TZTIME functionality introduced in 2.1.0, and needless to say mongrel still doesn’t work. Nor do the postgres or mysql gems, for that matter, although sqlite3 seems good to go - you ain’t gonna be switching to 1.9 anytime soon on your production site.
However, it runs, and if it runs, we can benchmark it!
I’ll use my /api/pulse controller action from previous testing. This is going to be Webrick-only, thin installs and seems to work until I load a page and then bombs out. Anyway.
The only modifications to the default rails application I am making here are to change the shebang line in script/server to point to 1.9, and to remove a couple of lines in boot.rb which check for RubyGems versions but bomb out for some reason in 1.9. Everything else is clean and Rails is installed as a gem under the 1.9.0 tree.
Webrick still has some problems under 1.9.0. Running with too high a concurrency seems to freak it out on 1.9.0, so I’ve turned the concurrency down to 5. Also, 1.9.0 is handily faster than 1.8.6 in development mode .. but in production mode, uh, you’ll see.
Ruby 1.8.6:
$ ab -n 500 -c 5 http://0.0.0.0:3000/api/pulse This is ApacheBench, Version 2.0.40-dev <$Revision: 1.146 $> apache-2.0 Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/ Copyright 2006 The Apache Software Foundation, http://www.apache.org/ Benchmarking 0.0.0.0 (be patient) Completed 100 requests Completed 200 requests Completed 300 requests Completed 400 requests Finished 500 requests Server Software: WEBrick/1.3.1 Server Hostname: 0.0.0.0 Server Port: 3000 Document Path: /api/pulse Document Length: 2 bytes Concurrency Level: 5 Time taken for tests: 2.67175 seconds Complete requests: 500 Failed requests: 0 Write errors: 0 Total transferred: 139000 bytes HTML transferred: 1000 bytes Requests per second: 241.88 [#/sec] (mean) Time per request: 20.672 [ms] (mean) Time per request: 4.134 [ms] (mean, across all concurrent requests) Transfer rate: 65.31 [Kbytes/sec] received Connection Times (ms) min mean[+/-sd] median max Connect: 0 0 0.0 0 1 Processing: 9 20 13.1 17 85 Waiting: 7 17 12.5 15 84 Total: 9 20 13.1 17 85 Percentage of the requests served within a certain time (ms) 50% 17 66% 18 75% 18 80% 19 90% 20 95% 25 98% 84 99% 84 100% 85 (longest request)
Ruby 1.9.0:
$ ab -n 500 -c 5 http://0.0.0.0:3000/api/pulse This is ApacheBench, Version 2.0.40-dev <$Revision: 1.146 $> apache-2.0 Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/ Copyright 2006 The Apache Software Foundation, http://www.apache.org/ Benchmarking 0.0.0.0 (be patient) Completed 100 requests Completed 200 requests Completed 300 requests Completed 400 requests Finished 500 requests Server Software: WEBrick/1.3.1 Server Hostname: 0.0.0.0 Server Port: 3000 Document Path: /api/pulse Document Length: 2 bytes Concurrency Level: 5 Time taken for tests: 3.921955 seconds Complete requests: 500 Failed requests: 0 Write errors: 0 Total transferred: 139000 bytes HTML transferred: 1000 bytes Requests per second: 127.49 [#/sec] (mean) Time per request: 39.220 [ms] (mean) Time per request: 7.844 [ms] (mean, across all concurrent requests) Transfer rate: 34.42 [Kbytes/sec] received Connection Times (ms) min mean[+/-sd] median max Connect: 0 0 0.0 0 0 Processing: 21 38 10.5 36 83 Waiting: 13 24 9.4 22 68 Total: 21 38 10.5 36 83 Percentage of the requests served within a certain time (ms) 50% 36 66% 38 75% 39 80% 40 90% 46 95% 69 98% 73 99% 74 100% 83 (longest request)
Well, I said it runs, I didn’t say it runs well. Seems to be a problem with Webrick, probably related to the concurrency issue. By comparison, in development mode the numbers are about 42reqs/sec (1.9.0) vs around 33reqs/sec(1.8.6). Still - giant leap from even a couple of months ago, and I look forward to further leaps in the near future.
The next step is to get a real web server running. This will probably be Thin, once I figure out how to get around the , I know that it should work, others are already using it on 1.9, though not with Rails. Any ideas welcome!
UPDATED to try and workaround concurrency issues with Webrick under 1.9.0
UPDATE 2: Duh, I was running on development.