How to debug a Rails asset precompile which is unbearably slow

后端 未结 3 1220
遥遥无期
遥遥无期 2021-01-30 13:09

I\'m working on a Rails 3.2 project and the assets have increased a fair bit in recent months although I wouldn\'t consider the project to be large. The assets consist of JS (no

3条回答
  •  刺人心
    刺人心 (楼主)
    2021-01-30 13:46

    there is a bunch of possible causes to this issue.

    for a possible cause, i would like to know how the time of compiling the assets increased in the several environments for your last deploys. this might indicate if the problem is just on the environments or within the asset compilation itself. you could use git bisect for that. i usually have my apps deployed to staging via a jenkins or another ci system so that i can see any variations in deploy time and when they were introduced.

    it might boil down to extensive use of resources CPU, MEMORY (any swap?), IO. if you compile the assets on the production systems they might be busy serving your applications request. go to your system, do a top for resources, maybe there are too many file handles at the same time (lsof is good for that).

    another thing might be that you load or cache some data for your application. databases are usually much larger in staging and production environments then they are on dev boxes. you could just put some Rails.logger calls in your initializers or whaterver.

提交回复
热议问题