2
votes

I'm running an spree 3, rails 4.2.2 site with Postgres as DB engine, Apache/2.4.7 as webserver (through passenger) and redis and I've been experimenting a lot of issues with the speed on my production environment. The load average goes crazy from time to time for no specific reason. Although, I noticed that this happens when new connections hit the site. Then the server's load average goes above 7 and most of the times I end up restarting apache.

Here are the server features:

  • 1GB RAM
  • Ubuntu 14.04.3 LTS
  • 80 GB hard disk

Here's my config/environments/production.rb setup:

Rails.application.configure do
  config.cache_classes = true
  config.eager_load = false
  config.consider_all_requests_local       = false
  config.action_controller.perform_caching = true
  config.assets.digest = true 
  config.log_level = :info
  config.force_ssl = true
  config.action_mailer.smtp_settings = {:enable_starttls_auto => false}
  config.action_mailer.delivery_method = :sendmail    
  config.action_mailer.perform_deliveries = true
  config.action_mailer.raise_delivery_errors = true
  Rails.application.config.middleware.use ExceptionNotification::Rack,
  :email => {
  :email_prefix => "[PRODUCTION] ",
  :sender_address => %{"notifier" <errors@something.com>},
  :exception_recipients => %w{team@something.com}
  }
end

I have set up newrelic but hasn't been very helpful so far.

What do you think I can do to speed up this environment? Any help will be really appreciated.

1

1 Answers

2
votes

Performance is one of those things that is really app specific. We just had to switch to Heroku's high-performance dynos to open up the memory enough for our Spree 2.3 app, so I know first-hand that Spree can be a memory hog.

Just guessing, I would lay money on a memory issue, but if you are really interested in solving the problem, and getting some amazing knowledge, I would recommend the course at:

https://www.railsspeed.com/

Nate Berkopec goes through the full stack of a rails application and gives specific examples of how to determine issues and solve them.

Check out his blog first before you buy to see if it vibes with you https://www.nateberkopec.com/. Some great answers there as well.

Alternatively, if you prefer a book format, the pragmatic programmers have a book on Ruby Performance Optimization which is pretty solid.

Both of those sources will have you start using rack-mini-profiler, so that might be an option as well to investigate.

Hope it helps!