Ruby on rails 升级到Rails 5.1.3后,Rails应用程序启动非常慢

Ruby on rails 升级到Rails 5.1.3后,Rails应用程序启动非常慢,ruby-on-rails,ruby,performance,asset-pipeline,pivotal-web-services,Ruby On Rails,Ruby,Performance,Asset Pipeline,Pivotal Web Services,我在Pivotal Web服务上运行Rails 5.1.3应用程序。由于从Rails 4升级,应用程序具有以下行为: 部署运行良好 彪马出发了 容器是健康的 第一个连接的客户机等待2到3分钟后才被送达第一页;在此期间,服务器将使用高达100%的CPU 在实例化新实例时也会发生这种情况 我尝试过更改“急切加载”设置的真假,但没有看到行为的变化 config.eager_load = true 我已经测试了有无机架cors gem,也没有任何变化 这是我的config/application.

我在Pivotal Web服务上运行Rails 5.1.3应用程序。由于从Rails 4升级,应用程序具有以下行为:

  • 部署运行良好
  • 彪马出发了
  • 容器是健康的
  • 第一个连接的客户机等待2到3分钟后才被送达第一页;在此期间,服务器将使用高达100%的CPU
在实例化新实例时也会发生这种情况

我尝试过更改“急切加载”设置的真假,但没有看到行为的变化

config.eager_load = true
我已经测试了有无机架cors gem,也没有任何变化

这是我的config/application.rb:

require_relative 'boot'

require "rails"
# Pick the frameworks you want:
require "active_model/railtie"
require "active_job/railtie"
require "action_controller/railtie"
require "action_mailer/railtie"
require "action_view/railtie"
require "sprockets/railtie"
require "rails/test_unit/railtie"
require 'pdfkit'

# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.

Bundler.require(*Rails.groups)

module MyFaro
  class Application < Rails::Application
    # Initialize configuration defaults for originally generated Rails version.
    config.load_defaults 5.1

    # Settings in config/environments/* take precedence over those specified here.
    # Application configuration should go into files in config/initializers
    # -- all .rb files in that directory are automatically loaded.

    # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
    # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
    config.time_zone = 'Brussels'

    # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
    #config.i18n.load_path = Dir[Rails.root.join('config', 'locales', '*.{rb,yml}').to_s]
    config.i18n.default_locale = :nl

    #config.skylight.probes += %w(mongoid mongo)

    config.middleware.use PDFKit::Middleware, {:print_media_type => true}, :only => %r[/print_story]

    config.after_initialize do
      ApplicationController.helpers.cache_set_look_up_hash
      ApplicationController.helpers.cache_set_system_parameter_hash
    end
  end
end

您的Pivotal Web Services实例有多少内存?我每个实例有2 GB内存,但随着时间的推移,这些实例只会增长到1或1.2 GB。它们在最初几分钟后运行正常。当没有客户使用时,您的实例是否进入休眠模式?在实例处于休眠状态时,这种情况非常常见。不确定-如何检查?这种情况会在部署后立即发生,客户端在容器运行正常的几秒钟内连接,我在早上重新连接实例时看不到这种情况。您的关键Web服务实例有多少内存?我每个实例有2 GB内存,但随着时间的推移,实例只会增长到1或1.2 GB。它们在最初几分钟后运行正常。当没有客户使用时,您的实例是否进入休眠模式?在实例处于休眠状态时,这种情况非常常见。不确定-如何检查?这种情况会在部署后立即发生,客户端在容器正常运行的几秒钟内连接,例如早上重新连接时,我看不到这种行为
Rails.application.configure do
  # Settings specified here will take precedence over those in config/application.rb.

  #CORS
  config.middleware.insert_before 0, Rack::Cors do
    allow do
      origins '*'
      resource '*', :headers => :any, :methods => [:get, :post, :options]
    end
  end

  # Code is not reloaded between requests.
  config.cache_classes = true

  # Eager load code on boot. This eager loads most of Rails and
  # your application in memory, allowing both threaded web servers
  # and those relying on copy on write to perform better.
  # Rake tasks automatically ignore this option for performance.
  config.eager_load = true

  # Full error reports are disabled and caching is turned on.
  config.consider_all_requests_local       = false
  config.action_controller.perform_caching = true
  config.cache_store = :memory_store

  # Attempt to read encrypted secrets from `config/secrets.yml.enc`.
  # Requires an encryption key in `ENV["RAILS_MASTER_KEY"]` or
  # `config/secrets.yml.key`.
  config.read_encrypted_secrets = true

  # Disable serving static files from the `/public` folder by default since
  # Apache or NGINX already handles this.
  config.public_file_server.enabled = true

  # Compress JavaScripts and CSS.
  config.assets.js_compressor = :uglifier
  # config.assets.css_compressor = :sass