Rails 3 70% slower than Rails 2.3.5?

I have finished converting my live apps to Rails 3.

I am using Ruby Enterprise 1.8.7 and Passenger 2.2.15

I go from 5.31 trans/sec to 3.05 trans/sec per AWS EC2 instance.

$ siege -c 5 -t 1M http://localhost

RAILS 2.3.5 RESULTS
Transactions: 320 hits
Availability: 100.00 %
Elapsed time: 60.26 secs
Data transferred: 6.76 MB
Response time: 0.45 secs
Transaction rate: 5.31 trans/sec
Throughput: 0.11 MB/sec
Concurrency: 2.41
Successful transactions: 320
Failed transactions: 0
Longest transaction: 1.05
Shortest transaction: 0.25

RAILS 3
Transactions: 169 hits
Availability: 100.00 %
Elapsed time: 55.38 secs
Data transferred: 3.72 MB
Response time: 1.06 secs
Transaction rate: 3.05 trans/sec
Throughput: 0.07 MB/sec
Concurrency: 3.23
Successful transactions: 169
Failed transactions: 0
Longest transaction: 1.74
Shortest transaction: 0.58

This is my passenger settings
PassengerRoot /opt/ruby-1.8.7/lib/ruby/gems/1.8/gems/passenger-2.2.15
PassengerRuby /opt/ruby-1.8.7/bin/ruby
PassengerMaxPoolSize 6
PassengerUseGlobalQueue on
PassengerHighPerformance on

I removed Passenger from the equation, and let this be script/server -e
production (Rails 2.3.5) vs. rails server -e production (Rails 3).

The difference is even greater.

BTW. I am on Ubuntu 10.4.

RAILS 2.3.5
Transactions: 109 hits
Availability: 100.00 %
Elapsed time: 59.77 secs
Data transferred: 23.80 MB
Response time: 2.20 secs
Transaction rate: 1.82 trans/sec
Throughput: 0.40 MB/sec
Concurrency: 4.01
Successful transactions: 109
Failed transactions: 0
Longest transaction: 2.99
Shortest transaction: 0.53

RAILS 3
Transactions: 312 hits
Availability: 100.00 %
Elapsed time: 60.32 secs
Data transferred: 68.81 MB
Response time: 0.44 secs
Transaction rate: 5.17 trans/sec
Throughput: 1.14 MB/sec
Concurrency: 2.29
Successful transactions: 312
Failed transactions: 0
Longest transaction: 0.99
Shortest transaction: 0.10

Sharkie L. wrote:

I removed Passenger from the equation, and let this be script/server -e
production (Rails 2.3.5) vs. rails server -e production (Rails 3).

The difference is even greater.

But in the other direction. Look at your figures again: you’re getting
1.82 trans/sec with 2.3.5 and 5.17 trans/sec with 3.

Best,

Marnen Laibow-Koser
http://www.marnen.org
[email protected]

I seriously apologize: I mislabeled my second results.

Rails 2.3.5 is much faster than Rails 3

One other difference is that Rails 2.3.5 is running on Ruby Enterprise
1.8.6 and Rails 3 is running on Ruby Enterprise 1.8.7 both on Ubuntu.

RAILS 2.3.5
Transactions: 312 hits
Availability: 100.00 %
Elapsed time: 60.32 secs
Data transferred: 68.81 MB
Response time: 0.44 secs
Transaction rate: 5.17 trans/sec
Throughput: 1.14 MB/sec
Concurrency: 2.29
Successful transactions: 312
Failed transactions: 0
Longest transaction: 0.99
Shortest transaction: 0.10

RAILS 3
Transactions: 109 hits
Availability: 100.00 %
Elapsed time: 59.77 secs
Data transferred: 23.80 MB
Response time: 2.20 secs
Transaction rate: 1.82 trans/sec
Throughput: 0.40 MB/sec
Concurrency: 4.01
Successful transactions: 109
Failed transactions: 0
Longest transaction: 2.99
Shortest transaction: 0.53

The problem could be with ActiveRecord performance.

Rails 2.3.5

puts Benchmark.measure{5000.times{User.find :first, :conditions => [“id
= ?”, (rand * 1000 + 1).to_i]}}
1.500000 0.100000 1.600000 ( 2.371361)

Rails 3.0

puts Benchmark.measure{5000.times{User.find :first, :conditions => [“id
= ?”, (rand * 1000 + 1).to_i]}}
8.160000 0.160000 8.320000 ( 15.330955)

Is this a known problem?

Everything else aside, isn’t going from 5.31 to 3.05 trans/sec 43%
slower?

Fred

I can also reproduce this problem on my Macbook Pro using Snow Leopard
10.6.4

Rails 2.3.5
puts Benchmark.measure{5000.times{User.find :first, :conditions => [“id
= ?”, (rand * 1000 + 1).to_i]}}
2.460000 0.440000 2.900000 ( 20.093052)

Rails 3.0
puts Benchmark.measure{5000.times{User.find :first, :conditions => [“id
= ?”, (rand * 1000 + 1).to_i]}}
9.100000 0.810000 9.910000 ( 28.481634)