2012-02-27 130 views
-2

Amazon EC2上的Ruby on Rails應用程序(Ubuntu 10.10)運行正常,但在服務器上啓動Ruby on Rails控制檯時運行速度非常慢。大約需要3〜5分鐘才能啓動Ruby on Rails控制檯。使用top我可以看到Ruby過程正在使用99%CPU時間。這太慢了。爲什麼?爲什麼Ruby on Rails控制檯啓動速度很慢?

我使用Ruby 1.9.2p290和Ruby on Rails 3.1.1。我的Ruby on Rails的gemfile.lock

GEM 
    remote: http://rubygems.org/ 
    specs: 
    actionmailer (3.1.1) 
     actionpack (= 3.1.1) 
     mail (~> 2.3.0) 
    actionpack (3.1.1) 
     activemodel (= 3.1.1) 
     activesupport (= 3.1.1) 
     builder (~> 3.0.0) 
     erubis (~> 2.7.0) 
     i18n (~> 0.6) 
     rack (~> 1.3.2) 
     rack-cache (~> 1.1) 
     rack-mount (~> 0.8.2) 
     rack-test (~> 0.6.1) 
     sprockets (~> 2.0.2) 
    active_utils (1.0.2) 
     activesupport (>= 2.3.11) 
     i18n 
    activeadmin (0.4.0) 
     bourbon (>= 1.0.0) 
     devise (>= 1.1.2) 
     fastercsv 
     formtastic (>= 2.0.0) 
     inherited_resources (< 1.3.0) 
     jquery-rails (>= 1.0.0) 
     kaminari (>= 0.13.0) 
     meta_search (>= 0.9.2) 
     rails (>= 3.0.0) 
     sass (>= 3.1.0) 
    activemerchant (1.20.2) 
     active_utils (>= 1.0.2) 
     activesupport (>= 2.3.11) 
     braintree (>= 2.0.0) 
     builder (>= 2.0.0) 
     i18n 
     json (>= 1.5.1) 
     money (<= 3.7.1) 
    activemerchant_patch_for_china (0.1.6) 
     activemerchant (>= 1.4.2) 
    activemodel (3.1.1) 
     activesupport (= 3.1.1) 
     builder (~> 3.0.0) 
     i18n (~> 0.6) 
    activerecord (3.1.1) 
     activemodel (= 3.1.1) 
     activesupport (= 3.1.1) 
     arel (~> 2.2.1) 
     tzinfo (~> 0.3.29) 
    activeresource (3.1.1) 
     activemodel (= 3.1.1) 
     activesupport (= 3.1.1) 
    activesupport (3.1.1) 
     multi_json (~> 1.0) 
    arel (2.2.1) 
    bcrypt-ruby (3.0.1) 
    bourbon (1.3.6) 
     sass (>= 3.1) 
    braintree (2.13.2) 
     builder (>= 2.0.0) 
    builder (3.0.0) 
    devise (2.0.0) 
     bcrypt-ruby (~> 3.0) 
     orm_adapter (~> 0.0.3) 
     railties (~> 3.1) 
     warden (~> 1.1) 
    erubis (2.7.0) 
    execjs (1.2.9) 
     multi_json (~> 1.0) 
    fastercsv (1.5.4) 
    formtastic (2.0.2) 
     rails (~> 3.0) 
    gravatar_image_tag (1.0.0) 
    guid (0.1.1) 
    has_scope (0.5.1) 
    hike (1.2.1) 
    i18n (0.6.0) 
    inherited_resources (1.2.2) 
     has_scope (~> 0.5.0) 
     responders (~> 0.6.0) 
    jquery-rails (1.0.19) 
     railties (~> 3.0) 
     thor (~> 0.14) 
    json (1.6.1) 
    kaminari (0.13.0) 
     actionpack (>= 3.0.0) 
     activesupport (>= 3.0.0) 
     railties (>= 3.0.0) 
    libv8 (3.3.10.4) 
    mail (2.3.0) 
     i18n (>= 0.4.0) 
     mime-types (~> 1.16) 
     treetop (~> 1.4.8) 
    meta_search (1.1.3) 
     actionpack (~> 3.1) 
     activerecord (~> 3.1) 
     activesupport (~> 3.1) 
     polyamorous (~> 0.5.0) 
    mime-types (1.17.2) 
    money (3.7.1) 
     i18n (~> 0.4) 
    multi_json (1.0.3) 
    orm_adapter (0.0.6) 
    polyamorous (0.5.0) 
     activerecord (~> 3.0) 
    polyglot (0.3.3) 
    rack (1.3.5) 
    rack-cache (1.1) 
     rack (>= 0.4) 
    rack-mount (0.8.3) 
     rack (>= 1.0.0) 
    rack-ssl (1.3.2) 
     rack 
    rack-test (0.6.1) 
     rack (>= 1.0) 
    rails (3.1.1) 
     actionmailer (= 3.1.1) 
     actionpack (= 3.1.1) 
     activerecord (= 3.1.1) 
     activeresource (= 3.1.1) 
     activesupport (= 3.1.1) 
     bundler (~> 1.0) 
     railties (= 3.1.1) 
    railties (3.1.1) 
     actionpack (= 3.1.1) 
     activesupport (= 3.1.1) 
     rack-ssl (~> 1.3.2) 
     rake (>= 0.8.7) 
     rdoc (~> 3.4) 
     thor (~> 0.14.6) 
    rake (0.9.2.2) 
    rdoc (3.11) 
     json (~> 1.4) 
    responders (0.6.5) 
    sass (3.1.14) 
    sass-rails (3.1.5) 
     actionpack (~> 3.1.0) 
     railties (~> 3.1.0) 
     sass (~> 3.1.10) 
     tilt (~> 1.3.2) 
    sprockets (2.0.3) 
     hike (~> 1.2) 
     rack (~> 1.0) 
     tilt (~> 1.1, != 1.3.0) 
    sqlite3 (1.3.4) 
    therubyracer (0.9.9) 
     libv8 (~> 3.3.10) 
    thor (0.14.6) 
    tilt (1.3.3) 
    treetop (1.4.10) 
     polyglot 
     polyglot (>= 0.3.1) 
    tzinfo (0.3.31) 
    uglifier (1.1.0) 
     execjs (>= 0.3.0) 
     multi_json (>= 1.0.2) 
    warden (1.1.0) 
     rack (>= 1.0) 
    will_paginate (3.0.2) 

PLATFORMS 
    ruby 

DEPENDENCIES 
    activeadmin 
    activemerchant 
    activemerchant_patch_for_china 
    gravatar_image_tag 
    guid 
    jquery-rails 
    meta_search (>= 1.1.0.pre) 
    rails (= 3.1.1) 
    sass-rails 
    sqlite3 
    therubyracer 
    uglifier (>= 1.0.3) 
    will_paginate 

我還發現rake db:migrate在服務器很慢過,就像Ruby on Rails的控制檯。

+0

也許相關:https://github.com/rubygems/rubygems/issues/99 – 2012-02-27 13:34:22

+0

我不明白你爲什麼downvote有效的答案。我在發佈時清楚地編輯了您的問題。請閱讀最新的回覆。另外,提供你的實例大小的細節(你沒有) – 2012-02-27 13:36:26

+0

我不是downvote你。我正在使用免費的EC2實例。 – 51beidanci 2012-02-28 04:58:36

回答

1

更新:似乎你在編輯我的答案時更新了你的問題。

它可能會開始緩慢,因爲它可能會交換。 EC2因緩慢而着稱,並且取決於您爲EC2選擇的實例大小,Rails應用程序可能會佔用您的所有內存。

前面的問題:

LMGTFY:http://rack.rubyforge.org/

最有可能你使用的客運服務將使用一個機櫃適配器(和配置),以將其加載到Rails應用程序。

你所看到的就是那個,你的應用程序在Rack後面運行。

如果您認爲它使用了大量內存:嘗試減少您的依賴關係,因爲您添加的寶石越多,內存中加載的東西就越多。

例如,您可以更改therubyracer(取決於libv8),並將其替換爲NodeJS。這會稍微減少應用程序的內存佔用量。

+0

謝謝你,路易斯。我目前正在爲一個在m1.small實例上使用EC2的相當寶石般的應用程序測試一個臨時安裝。這是一個非常小的。我在原始和更新的帖子中遇到了問題。你有最小實例大小,你發現工作得很好嗎? – 2013-03-13 03:59:20

相關問題