Ruby On Rails is slow…?

后端 未结 11 1831
说谎
说谎 2021-01-31 23:50

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

11条回答
  •  醉话见心
    2021-02-01 00:17

    I'll agree with everyone else. You have to profile. There is no point in doing anything to your code until you know what specifically is causing the slowness. Trying to fixing a problem without understanding the cause is like feeling ill and deciding to have lots of surgery until you feel better. Diagnose your problem first. It might be something small like a network setting or it could be one bad line in your code.

    Some tips for profiling:

    How to Profile Your Rails Application

    Performance Testing Rails Applications

    At the Forge - Profiling Rails Applications

    Once you have found the bottleneck you can figure out what to do.

    I recommend these videos: Railslab Scaling Rails

    Revised now based on prof results:

    OK. Now that you can see that your problem is that you are doing some sort of calculation using a query based on looping through the results of another active record query I'd advise you to look into building a custom SQL statement combining your initial selection criteria and the loop calculation to get what you need. You can definitely speed this up by optimizing the SQL.

提交回复
热议问题