Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7726027
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T05:06:28+00:00 2026-06-01T05:06:28+00:00

I’m using Rails 3.0.0 + passenger + apache2 running on Ruby 1.9.2p290 on an

  • 0

I’m using Rails 3.0.0 + passenger + apache2 running on Ruby 1.9.2p290 on an ec2 instance.

Relevant Passenger settings (I’ve messed with them extensively to no effect):

PassengerMaxPoolSize 30
PassengerPoolIdleTime 0
PassengerMinInstances 10

Also, I have verified I am NOT memory or CPU bound…

I’ve run some benchmarks and am very confused by the results. I have call that does a fairly complex query that chains 5 different .where() clauses together. (In other words, it uses AREL quite a bit.)

When I run Apache Bench with 1000 calls WITHOUT CONCURRENCY (e.g, ab -n 1000 -c 1), I get the following:

 Concurrency Level:      1
 Time taken for tests:   222.799 seconds
 Complete requests:      1000
 Failed requests:        0
 Write errors:           0
 Total transferred:      489000 bytes
 HTML transferred:       16000 bytes
 Requests per second:    4.49 [#/sec] (mean)
 Time per request:       222.799 [ms] (mean)
 Time per request:       222.799 [ms] (mean, across all concurrent requests)
 Transfer rate:          2.14 [Kbytes/sec] received

Now when I run it with concurrency set to 10 (e.g, ab -n 1000 -c 10), I get the following:

 Concurrency Level:      10
 Time taken for tests:   213.957 seconds
 Complete requests:      1000
 Failed requests:        0
 Write errors:           0
 Total transferred:      489001 bytes
 HTML transferred:       16000 bytes
 Requests per second:    4.67 [#/sec] (mean)
 Time per request:       2139.567 [ms] (mean)
 Time per request:       213.957 [ms] (mean, across all concurrent requests)
 Transfer rate:          2.23 [Kbytes/sec] received

There’s absolutely no benefit from concurrent requests! The request per second is still at ~4.5. It’s as though the server is handling requests serially.

Now for the really weird part. If I look at the outputted SQL query from the ActiveRecord query interface and instead just use find_by_sql, I get this with no concurrency:

 Concurrency Level:      1
 Time taken for tests:   49.547 seconds
 Complete requests:      1000
 Failed requests:        0
 Write errors:           0
 Total transferred:      489000 bytes
 HTML transferred:       16000 bytes
 Requests per second:    20.18 [#/sec] (mean)
 Time per request:       49.547 [ms] (mean)
 Time per request:       49.547 [ms] (mean, across all concurrent requests)
 Transfer rate:          9.64 [Kbytes/sec] received

No surprises here. find_by_sql is faster than using ActiveRecord and AREL to construct queries. BUT, if I run the previous with concurrency set to 10, I get:

 Concurrency Level:      10
 Time taken for tests:   17.859 seconds
 Complete requests:      1000
 Failed requests:        0
 Write errors:           0
 Total transferred:      489000 bytes
 HTML transferred:       16000 bytes
 Requests per second:    55.99 [#/sec] (mean)
 Time per request:       178.587 [ms] (mean)
 Time per request:       17.859 [ms] (mean, across all concurrent requests)
 Transfer rate:          26.74 [Kbytes/sec] received

Notice how the requests per second jumps 3-fold. So my question:

How/Why does using ActiveRecord (and AREL) to build queries cause concurrent requests to respond so poorly? Could ActiveRecord really be that CPU intensive?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T05:06:29+00:00Added an answer on June 1, 2026 at 5:06 am

    Without seeing your actual code, I would guess that AREL produces less-than-optimal SQL for the query you give it, resulting in the database being bogged down.

    Compare the SQL statement produced by AREL with your own SQL. Also try running AREL’s query directly in your database to see how its performance compares with your SQL. Try an EXPLAIN on both queries. Keep in mind that some databases get worse at optimising SQL as it gets more complex.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We're building an app, our first using Rails 3, and we're having to build
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am reading a book about Javascript and jQuery and using one of the
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
We are using XSLT to translate a RIXML file to XML. Our RIXML contains

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.