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 sl
This is not normal. You have some logic that is slowing you down. Trying commenting out bits and pieces of your code that you think are taking a long time and see if that helps. If it does then you need to figure out how to optimize that logic.
If you are doing lots of calculations over a loop iterating through a very large number of objects, then of course it will be slow.
These types of issues can come up in any language or framework. While Ruby is not as fast as other languages, it's fast enough most of the time. If you need to constantly calculate with large data sets then Ruby may not be the right language for you. Look into writing a Ruby C extension that will handle your performance draining code. But first just try to diagnose and refactor.
Lastly, check out RubyProf to see if it can help you find the bottleneck.
The previous two answers are helpful, especially using performance monitoring tools. I use New Relic RPM and it's helped me a great deal in the past.
However, these sorts of tools are really best when you're trying to speed up from, say, 3 seconds to under 1 second.
2-4 minutes for a view to render is absolutely not normal under any normal circumstances.
Could you show us some of your development logs to figure out where the bottlenecks are?
Are you including time the browser takes to load images, javascripts, or other files into this total measurement?
Why not pre-fetch all the data and have your for loop find it locally in memory, instead of querying the database each time? 1000s of queries for a single view indicates that something is seriously is wrong with your design.
You could try to use JRuby or switch to Ruby 1.9.
Both of them should result in massive performance boosts.
The problem with JRuby is that gems that use C won't compile/work. There are Java equivalents which are installed by jruby's "gem" app, but some of the gems simply don't work
You basically will have the same problem with Ruby 1.9. A little bit of syntax changed, but the main problem is that a hugh amount of gems don't work anymore. People are in the progress of updating though (check progress at http://isitruby19.com/)
When I bound the server to the boxes ip address instead of 0.0.0.0, this sped things up for me.
Execution times this long would make me suspect a network issue - maybe a DNS query is timing out on a primary DNS server?