简体   繁体   中英

Is the Rails 4.2 app taking too much memory?

Our Rails 4.2 app is taking 254MB physical memory running on a Ubuntu 14.04 server. Ruby app usually has large memory footprint. However 254MB still seems a lot.

The following is the Gemfile for the app. All the gems with :path are engines developed by ourselves. Is there way of reducing the physical memory footprint with better coding practice?

source 'http://rubygems.org'

gem 'rails', '4.2.0'

# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'

gem 'sqlite3'
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.1.0'
gem 'sdoc', '~> 0.4.0', group: :doc

gem 'sprockets', '2.12.3'
gem 'tilt', '~>1.4.1'
#gem 'turbolinks'  #cause datepicker stop working. removed from application.js.
gem 'jquery-rails' #, '2.3.0'   #may cause error with jquery-ui for version 3.0.0 for rails 3.2.12.
gem 'jquery-ui-rails'
gem 'database_cleaner'
gem 'simple_form', '~>3.1.0'
gem 'will_paginate'
gem 'gon'
#rails 4.2.0
gem 'tzinfo-data'  #, platforms: [:mingw_20, :mingw, :mswin]
gem 'protected_attributes'
#
#gem 'coffee-script-source', '1.8.0'  #ver reduced for windows platform


gem 'authentify', :path => '../engines/authentify'  #  
gem 'commonx', :path => '../engines/commonx'   #
gem 'purchase_orderx', :path => '../engines/purchase_orderx'
gem 'kustomerx', :path => '../engines/kustomerx'  #   #for rspec test  
gem 'supplierx',  :path => '../engines/supplierx'
gem 'manufacturerx', :path => '../engines/manufacturerx'
gem 'ext_construction_projectx',  :path => '../engines/ext_construction_projectx'
gem 'searchx', :path => '../engines/searchx'
gem 'biz_workflowx', :path => '../engines/biz_workflowx'
gem 'state_machine_logx', :path => '../engines/state_machine_logx'
gem 'base_materialx', :path => '../engines/base_materialx'
gem 'simple_contractx', :path => '../engines/simple_contractx'
gem 'in_paymentx', :path => '../engines/in_paymentx'
gem 'resource_allocx', :path => '../engines/resource_allocx'
gem 'payment_requestx',  :path => '../engines/payment_requestx'
gem 'status_reportx', :path => '../engines/status_reportx'
gem 'two_tier_definitionx', :path => '../engines/two_tier_definitionx'
gem 'user_manualx', :path => '../engines/user_manualx'
gem 'bill_of_base_materialx', :path => '../engines/bill_of_base_materialx'
#gem 'file_uploaderx', :path => '../engines/file_uploaderx'
gem 'bank_accountx', :path => '../engines/bank_accountx'

Our unicorn workers have an average of 260MB RSS and our gemlist is way longer than yours. I don't know all the gems you have there but you could try to track down huge allocations with ObjectSpace.count_objects (measure before and after requiring the library).

While saved RAM is always nice, 250 MB are okay in my opinion. Rails keeps a lot of stuff request independent in memory.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM