簡體   English   中英

為什么Ruby on Rails控制台啟動速度很慢?

[英]Why does the Ruby on Rails console start very slow?

我在Amazon EC2(Ubuntu 10.10)上的Ruby on Rails應用程序運行正常,但是在服務器上啟動Ruby on Rails控制台時非常慢。 啟動Ruby on Rails控制台大約需要3到5分鍾。 使用top我可以看到Ruby進程正在使用99%的CPU時間。 太慢了 為什么?

我正在使用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控制台一樣。

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

它可能開始變慢,因為它可能正在交換。 EC2速度緩慢,眾所周知,根據您為EC2選擇的實例大小,Rails應用程序可能會占用所有內存。

上一個問題:

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

很可能您正在使用Passenger來為Rails應用程序提供服務,該應用程序將使用Rack適配器(和配置)進行加載。

您所看到的是,您的應用程序在Rack后面運行。

如果您認為它占用大量內存:請嘗試減少依賴性,因為添加的gem越多,內存中就會加載越多的東西。

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM