Skip to content

Instantly share code, notes, and snippets.

@pcreux
Last active December 11, 2023 20:24
Show Gist options
  • Save pcreux/7680384 to your computer and use it in GitHub Desktop.
Save pcreux/7680384 to your computer and use it in GitHub Desktop.
Fast Rails + Heroku Configuration
group :production do
gem 'unicorn'
gem 'heroku-deflater'
gem 'rails_12factor'
end
gem 'memcachier'
gem 'dalli'
gem 'kgio'
gem 'rack-cache'
Refuge::Application.configure do
# Enable Rails's static asset server for Heroku
config.serve_static_assets = true
config.static_cache_control = "public, max-age=31536000"
config.cache_store = :dalli_store
client = Dalli::Client.new(ENV["MEMCACHIER_SERVERS"],
:value_max_bytes => 10485760,
:expires_in => 1.day)
config.action_dispatch.rack_cache = {
:metastore => client,
:entitystore => client
}
config.action_mailer.smtp_settings = {
:address => 'smtp.sendgrid.net',
:port => '587',
:authentication => :plain,
:user_name => ENV['SENDGRID_USERNAME'],
:password => ENV['SENDGRID_PASSWORD'],
:domain => 'heroku.com',
:enable_starttls_auto => true
}
end
@antoinelyset
Copy link

Awesome thanks !

@EtienneDepaulis
Copy link

Some suggestions:

  • sucker_punch (to avoir using workers for just emails)
  • add a comment on new relic regarding the monitoring feature to keep the app online without using external services

@boriscy
Copy link

boriscy commented Nov 28, 2013

sucker_punch is great but one must be really carefull if you aren't using ruby 2.0.

@mathieugagne
Copy link

Can't precompile assets: undefined method day' for 1:Fixnum expires_in` takes the "default TTL in seconds if you do not pass TTL as a parameter to an individual operation, defaults to 0 or forever" [source: http://www.rubydoc.info/github/mperham/dalli/Dalli/Client]
If it's 1 day you want then value should be 86400

client = Dalli::Client.new(ENV["MEMCACHIER_SERVERS"],
                             :value_max_bytes => 10485760,
                             :expires_in => 86400)

@croaky
Copy link

croaky commented Nov 30, 2013

These settings, minus Memcache, are in Suspenders. I prefer fronting my Heroku apps with Fastly to Memcache for the fastest static asset serving that only hits the Heroku dynos once per cache via origin pull.

@maurogeorge
Copy link

You can change the Sendgrid by the Mandrill. In the free plan, they have the double of emails.

@pcreux
Copy link
Author

pcreux commented Feb 22, 2014

@mathieugagne Thanks! I just fixed it!

@pcreux
Copy link
Author

pcreux commented Feb 22, 2014

@maurogeorge Done!

@pcreux
Copy link
Author

pcreux commented Feb 22, 2014

@croaky Fastly charges a minimum of $50 a month right?

@chuckbergeron
Copy link

Could use a gem 'newrelic' line in the Gemfile. I added the addon but missed the gem, and was wondering why Newrelic was "waiting on data" 😁

@jesuslerma
Copy link

do u need to have workers?

@chuckbergeron
Copy link

The command is now heroku addons:create instead of heroku addons:add

Also, heroku addons:add pgbackups:auto-month doesn't exist. The only postgres backup system I see now is heroku addons:create autobus

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment