Every time to POST a request
it takes me about 10~20 sec to stuck on the console.
What happened ? How to profile it ?
Started POST "/users" for 127.0.0.1 at 2015-01-07 11:20:43 +0800
Here's the gems are suspected to cause the slow response
gem 'quiet_assets'
gem "spring"
gem 'pry-rescue'
gem 'pry-byebug'
development.rb
# since you don't have to restart the web server when you make code changes.
config.cache_classes = false
# Do not eager load code on boot.
config.eager_load = false
# Show full error reports and disable caching.
config.consider_all_requests_local = true
config.action_controller.perform_caching = false
# Don't care if the mailer can't send.
config.action_mailer.raise_delivery_errors = false
# Print deprecation notices to the Rails logger.
config.active_support.deprecation = :log
# Raise an error on page load if there are pending migrations
config.active_record.migration_error = :page_load
# Debug mode disables concatenation and preprocessing of assets.
# This option may cause significant delays in view rendering with a large
# number of complex assets.
config.assets.debug = true
config.action_mailer.delivery_method = :smtp
config.action_mailer.raise_delivery_errors = true
config.action_mailer.default :charset => "utf-8"
--------------
I had a similar issue with slow performance, it became worse the larger your assets became. The solution, was that one line you have set to true in your development.rb file.
config.assets.debug = true
Change that to false and you should see a BIG improvement!
Related
Can't understand why my rails app become make response ultra-slow - in 1 minute!
As i see total time Rails should be: Views 0.2ms + ActiveRecord 219.5ms + Solr 379.7ms = 599.4ms
But it takes 62615ms, where is it spending the rest of time 62015.6ms?
Started POST "/applications/135" for ::1 at 2019-08-05 17:59:04 +0300
Processing by ApplicationController#create as JS
...
Completed 200 OK in 62615ms (Views: 0.2ms | ActiveRecord: 219.5ms | Solr: 379.7ms)
config/environments/development.rb:
# frozen_string_literal: true
require 'sidekiq/testing/inline'
Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# Verifies that versions and hashed value of the package contents in the project's package.json
config.webpacker.check_yarn_integrity = false
# In the development environment your application's code is reloaded on
# every request. This slows down response time but is perfect for development
# since you don't have to restart the web server when you make code changes.
config.cache_classes = false
# Do not eager load code on boot.
config.eager_load = false
# Show full error reports and disable caching.
config.consider_all_requests_local = true
config.action_controller.perform_caching = false
# Print deprecation notices to the Rails logger.
config.active_support.deprecation = :log
# Raise an error on page load if there are pending migrations.
config.active_record.migration_error = :page_load
# Debug mode disables concatenation and preprocessing of assets.
# This option may cause significant delays in view rendering with a large
# number of complex assets.
config.assets.debug = false
# Asset digests allow you to set far-future HTTP expiration dates on all assets,
# yet still be able to expire them through the digest params.
config.assets.digest = true
# Adds additional error checking when serving assets at runtime.
# Checks for improperly declared sprockets dependencies.
# Raises helpful error messages.
config.assets.raise_runtime_errors = true
# Raises error for missing translations
# config.action_view.raise_on_missing_translations = true
# SMTP configuration
config.action_mailer.default_url_options = {
host: ENV['HOST']
}
config.action_mailer.delivery_method = :letter_opener
config.action_mailer.perform_deliveries = true
# Care if the mailer can't send.
config.action_mailer.raise_delivery_errors = true
end
Found cause of slow down.
Somebody of our team added delayed service into the controller.
After commenting #require 'sidekiq/testing/inline' in the config/environments/development.rb and running separate sidekiq -C config/sidekiq.yml it solved the problem, now service is running asynchronously.
But problem was inside the service where was the call RestClient.post(endpoint, payload.to_json, 'api-key': api_key) which was wrapped into begin rescue end block that catch the error (that raises in a minute by RestClient timeout).
Completed 401 Unauthorized in 62562ms (ActiveRecord: 191.5ms)
RestClient::Exceptions::ReadTimeout (Timed out reading data from server):
am trying to push my rails 4 app on heroku but getting this error:
Error connecting to Redis on 127.0.0.1:6379 (ECONNREFUSED) (Redis::CannotConnectError)
on heroku logs, i have completed the RedisToGo setup as suggested by the heroku devcenter
but nothing happened i think am doing something wrong with RedisToGo URL
redis.rb
uri = URI.parse(ENV["REDIS_URL"] || "redis://redistogo:0deb5da103a95090a365444d016c59a6#angelfish.redistogo.com:9308/" )
$redis = Redis.new(:host => uri.host, :port => uri.port, :password => uri.password)
my development.rb
Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# In the development environment your application's code is reloaded on
# every request. This slows down response time but is perfect for development
# since you don't have to restart the web server when you make code changes.
config.cache_classes = false
# Do not eager load code on boot.
config.eager_load = false
# Show full error reports and disable caching.
config.consider_all_requests_local = true
config.action_controller.perform_caching = false
# Action Mailer configuration
config.action_mailer.raise_delivery_errors = true
config.action_mailer.delivery_method = :test
config.action_mailer.default_url_options = { host: 'localhost', port: 3000 }
# Print deprecation notices to the Rails logger.
config.active_support.deprecation = :log
# Raise an error on page load if there are pending migrations.
config.active_record.migration_error = :page_load
# Debug mode disables concatenation and preprocessing of assets.
# This option may cause significant delays in view rendering with a large
# number of complex assets.
config.assets.debug = true
# Asset digests allow you to set far-future HTTP expiration dates on all assets,
# yet still be able to expire them through the digest params.
config.assets.digest = true
# Adds additional error checking when serving assets at runtime.
# Checks for improperly declared sprockets dependencies.
# Raises helpful error messages.
config.assets.raise_runtime_errors = true
ENV["REDISTOGO_URL"] = 'redis://redistogo:0deb5da103a95090a365444d016c59a6#angelfish.redistogo.com:9308/'
# Raises error for missing translations
# config.action_view.raise_on_missing_translations = true
# React configurations.
config.react.variant = :development
config.react.addons = true
config.after_initialize do
Bullet.enable = true
Bullet.alert = true
end
end
I am working on Rails 4.2 & Angular 1.4.8 as the front-end. This is my development.rb file:
Rails.application.configure do
config.cache_classes = false
config.eager_load = false
config.action_controller.perform_caching = false
config.action_mailer.raise_delivery_errors = false
config.active_support.deprecation = :log
config.active_record.migration_error = :page_load
config.assets.debug = true
config.assets.raise_runtime_errors = true
config.action_mailer.delivery_method = :letter_opener_web
config.action_mailer.default_url_options = {host: "localhost:3000"}
config.consider_all_requests_local = false
end
I know that by disabling assets.debug I can really speed this up, but I need to have my assets refreshed when I refresh the page. I am doing full stack so I can't precompile assets all the time.
I recently started using guard with guard-rails - do I have any chance ?
I suspect that compiling all assets every time after file changed.
if you require angularjs libs and other libs in to application.js try to create a separate file for libraries and application
See also: Rails 3.1 is very slow in development-mode because of assets, what to do?
I am trying to change my styles of my scss assets on my ruby on rails project but they are applying just after rake assets:precompile and restarting rails server.
With JS files everything allright and they are changing on fly.
Possible problem is with compass gem.
That is my repo - https://github.com/tanotify/blog
And file development.rb
Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# In the development environment your application's code is reloaded on
# every request. This slows down response time but is perfect for development
# since you don't have to restart the web server when you make code changes.
config.cache_classes = false
# Do not eager load code on boot.
config.eager_load = false
# Show full error reports and disable caching.
config.consider_all_requests_local = true
config.action_controller.perform_caching = false
# Don't care if the mailer can't send.
config.action_mailer.raise_delivery_errors = false
# Print deprecation notices to the Rails logger.
config.active_support.deprecation = :log
# Raise an error on page load if there are pending migrations.
config.active_record.migration_error = :page_load
# Debug mode disables concatenation and preprocessing of assets.
# This option may cause significant delays in view rendering with a large
# number of complex assets.
config.assets.debug = true
# Asset digests allow you to set far-future HTTP expiration dates on all assets,
# yet still be able to expire them through the digest params.
config.assets.digest = true
# Adds additional error checking when serving assets at runtime.
# Checks for improperly declared sprockets dependencies.
# Raises helpful error messages.
config.assets.raise_runtime_errors = true
# Raises error for missing translations
# config.action_view.raise_on_missing_translations = true
config.action_mailer.default_url_options = { host: 'localhost', port: 3000 }
end
Found solution! In config/environments/development.rb added line:
config.serve_static_assets = false
What can cause Rails to run migrations every time?
I am deploying to a qa environment and migrations run everytime as if rails is setting up the entire database again.
here is my config/environments/qa.rb
Backend::Application.configure do
# Settings specified here will take precedence over those in config/application.rb
config.assets.compile = true
config.serve_static_assets = false
# In the development environment your application's code is reloaded on
# every request. This slows down response time but is perfect for development
# since you don't have to restart the web server when you make code changes.
config.cache_classes = false
# Log error messages when you accidentally call methods on nil.
config.whiny_nils = true
# Show full error reports and disable caching
config.consider_all_requests_local = true
config.action_controller.perform_caching = false
# Don't care if the mailer can't send
config.action_mailer.raise_delivery_errors = false
# Print deprecation notices to the Rails logger
config.active_support.deprecation = :log
# Only use best-standards-support built into browsers
config.action_dispatch.best_standards_support = :builtin
# Raise exception on mass assignment protection for Active Record models
config.active_record.mass_assignment_sanitizer = :strict
# Log the query plan for queries taking more than this (works
# with SQLite, MySQL, and PostgreSQL)
config.active_record.auto_explain_threshold_in_seconds = 0.5
# Do not compress assets
config.assets.compress = false
# Expands the lines which load the assets
config.assets.debug = true
# ActionMailer Config
config.action_mailer.default_url_options = { :host => 'localhost:3002' }
config.action_mailer.delivery_method = :smtp
# change to true to allow email to be sent during development
config.action_mailer.perform_deliveries = true
config.action_mailer.raise_delivery_errors = true
config.action_mailer.default :charset => "utf-8"
end
Edit: Rails 4.0 and 3.2 - rake db:migrate runs all migrations every time.
Edit: deploying with capistrano: cap qa deploy
It might be because you have migrate task in your Capistrano deploy file.
Check in config/deploy.rb if there is some variation of migrate (it could be "deploy:migrate" or full rake task).
Dope, I am so careless. I was using sqlite3. This meant that capistrano would create a new release and a new database everytime. This can be solved by linking to the database file.
I am electing to create a database hosted on AWS.