Note that there are some explanatory texts on larger screens.

plurals
  1. PORuby On Rails is slow...?
    text
    copied!<p>I'm writing a web application to monitor a furniture factory production flow. It has thousand of data to handle. So far, I run RoR on Mongrel + MySQL and it's really really slow (2-4min for some views). When I look at RoR logs, it seems that database queries aren't slow (0-10ms).</p> <p>Is RoR slow when it converts database data to object ? Is Mongrel slow ?</p> <p><strong>Edit</strong>: First thing: I was in dev. env. In production environment, the slowest view takes 2min (which would turn down to less than 1min on a good computer, mine is 5 years old). With ruby-prof and a bit of common sense, I've found out which methods were slowing down the application. The problem is that single sql queries are called in loops on larges datasets:</p> <pre><code>ofs = Ofkb.find_by_sql ["..some large sql query..."] for of in ofs # About 700-1000 elements ops = Operation.find(..the single query..) etc. end </code></pre> <p>Here are ruby-prof results on those methods:</p> <pre><code> %self total self wait child calls name 32.19 97.91 97.91 0.00 0.00 55 IO#gets (ruby_runtime:0} 28.31 86.39 86.08 0.00 0.32 32128 Mysql#query (ruby_runtime:0} 6.14 18.66 18.66 0.00 0.00 12432 IO#write (ruby_runtime:0} 0.80 2.53 2.42 0.00 0.11 32122 Mysql::Result#each_hash (ruby_runtime:0} </code></pre> <p>Problem is: I can't really avoid those single queries. I've got thousand of events from which I have to compute complex data. Right now I'm using memcached on those methods which is OK unless your the first to request the page.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload