I think the most immediate downside of Heroku is that the free tier comes with one dyno that must be booted back up after a short period of inactivity. In other words, the first user to visit your website in a while has to endure the wait until the dyno is spun back up.
Once you cough up the $35/month minimum for an extra dyno, then both dynos stay on. Just something to keep in mind when you're comparing practical price points.
@GuilhermeSimoes I took a different approach to this same feature.
In devise/registrations/new.html.erb:
ruby
link_to "Cancel registration using #{session['devise.omniauth'][:provider].titleize}", cancel_registration_path(resource)
(only if the 'devise.omniauth' session var is set)
I also switched to using 'devise.omniauth' because the devise documents say it cleans anything in the session that starts with 'devise' on successful authentication.
How different would the process be if the target was a non-vagrant Ubuntu server?
How would I ago about dealing with the absence of the vagrantfile?
I am trying to build a deployment that has the fewest possible components, and it seems to me that while nginx and unicorn are necessary, vagrant is not.
But I'd love to see more info on this. It seems like with rail's asset compilation, the max-age could be a year or more, since the url/filename will change with new new push. But please correct me if I'm wrong.
Is there any significant performance penalty for calling object.class.validators_on(name).any? (below) for every field? Would it be measurably better to move this array retrieval to the form level?
This was a very awesome tutorial, but I fumbled around a bit with adding in the username. It worked when I manually updated the db fron the console, but it didn't work when I tried to create a new account. Needed to add this to /models/users.rb:
# Setup accessible (or protected) attributes for your model
attr_accessible :email, :username, :password, :password_confirmation
For any rookies out there like me, don't forget to add :username to this line. :-)
Ryan Bates - You rock! Worked awesome locally and on Heroku.
This is a great screencast, but I'm having an issue that I can't seem to get around.
I deployed my app, but it comes up with a 500 error every time (with my custom 500 error html page). I tried looking in the log, but it doesn't seem to be logging anything at all, so I'm at a loss to figure out what my error is.
How did you get around the Twitter Bootstrap and Stripe issue?
I'm having issues in development mode where it's always returning an error with Invalid Token on the card. It's like it's trying to submit to Stripe with no card information.
Fantastic screencast Ryan! So many rails developers are bewildered by the deployment process or have no idea how to setup the stack from scratch.
While capistrano is indeed a great tool and allows you to maintain very complex setups, but overtime found it to overkill for simple webapps with just single production server and maybe a staging server. Having tried heroku I really think git is the way to go in this case. Setting up post–receive hook on the the server is really very simple and all your deployment boils down to running 'git push production localbranch:master'.
With regards to unicorn I really see no reason you chose it as oposed to phusion passenger. It is an extra dependency that needs to be maintained. For me the beauty of using passenger lies in the fact that I don't need to maintain a separate service and make sure it is running at all times.
Okay, good to know. I hope that server location will lose SEO significance. No idea why it keeps having influence these days. Wonder what's the reasoning behind it.
Problem with assets:precompile
Thanks to ryan I can deploy my app with capistrano now but evertime come the assets:precompile command it takes longer and longer.
In fact assets subdirectories are added everytime :
It looks like it compiles all assets recursively.
I thought it because I have : config.assets.precompile += ['*.js', '*.css'] but even if without the problem shows up.
We have tested yes! A resent client with heavy SEO development was ranking around bottom of page one for a number of years. With just the movement to UK server we have seen a 4 place growth with no extra SEO work done. Its a clear indication that it has an effect.
SEOMOZ still stands true with this as well if you search out there forums. But I do think It has come the day for it not to with cloud being so big now.
I've tried to set it up so i can deploy to both a staging and production server, but it hasn't worked out yet. Any spproach to go about it? Its basically the same set of tasks, but with a different server location. Something like cap staging:deploy and production:deploy etc.
I would check the following:
1. Make sure that your target server, e.g., Linode is known to your source, e.g., GitHub server.
2. Make sure that you can follow your script manually, i.e., type in each command on the terminal and see where you get asked a password related question and try to use public/private key authentication to automate the authentication process.
That should help you isolate the problem.
I doubt that the server IP has much influence on search engine rankings these days. But I'm curious: does anyone have experience with this? Done some tests?
I know you've gotten some responses but I'll throw in my 2 cents. If you're doing this for fun only then go with whatever you enjoy or challenges you. If you're doing it for money or for recognition, determine what your competitive advantage is/could-be and if either a VPS or Heroku can help you provide your customers with an advantage choose them. If neither of those are true pick one that you trust and can use effectively. I learned a ton by building systems in VPS and on various cloud providers, but at the end of the day rails is my passion (p.s. I work for Heroku). Everyone should know something about how servers are set up, only you can choose which provider is right for you.
It depends on how much control you want over your environment. If you're not expecting your app to have to scale much, you might go with a VPS. However, if you're expecting the app to grow rapidly and for your userbase and daily record commit to increase by a large margin, you might consider a hosted solution like Heroku or EngineYard. Both of those solutions scale very well up and down.
You can also send mails from that one dyno, unless you send bulk mails. I recommend sending those in a background process to not block your web dyno(s). Also note that dynos drop requests that are longer than 30 secs.
A permanently running background process needs at least 1 extra dyno which is 35$/month. But if you don't need a permanent process you can programatically start a dyno when a job is added to the job queue and stop it once it's finished. That way you keep cost low, as dynos are paid per hour.
For image processing I recommend storing the images on Amazon S3 which is rather cheap, check their pricing info for details. Heroku is not suitable for storing files, as dynos are not persisted so you'd loose all uploads after dyno restarts or deploys.
I took Justin's subscriptions.js file above and converted for new user and got the same results. Works fine in development mode but is essentially ignored in production mode. Other js files are working fine. Must be something in the asset pipeline configuration. Anybody else using this in production mode?
Im using carrier wave to store uploaded files, but when I do a deploy, those files get overwritten and are not longer accessible, cause they are in previous releases...I know I could use something like a3 for file storage, but I don't really require that right now...
Any ideas on what I might be able to do copy the previous deploys "upload" dir back into the "current" app?
Any reason this would not working in production mode? I know the code gets minified. I altered the code for new user but works great in development. I set break points in the deminified javascript and it is as it does not even get called. The new_user id is there in the HTML. This might be too heavy to post here but I feel it is something stupid that I missing. Thanks for any help. Here is a portion of the deminified javascript:
I don't think you will pay much more than $40.00.
Though, as you see here, if you do this on Linode, the cost will easily be halved. This is a rough estimate based on my personal experience however and I may easily be off.
Hello,
I am interrested in Heroku as well, it seems so easy and restful. My only concern is about the price, for a small commercial web-site, let's say 200 visit a day, some mailing processing and a bit of image processing, how much will I pay.
I would be greatful to have an estimation... could you help me?
Hello,
I am interrested in Heroku as well, it seems so easy and restful. My only concern is about the price, for a small commercial web-site, let's say 200 visit a day, some mailing processing and a bit of image processing, how much will I pay.
I would be greatful to have an estimation... could you help me?
Great job Ryan. Question: what if you're deploying to a test server first, then up to production? like so: Dev --> Test <--> Prod. The arrow goes both ways between test and prod because the prod database is sent to testing db and the testing code sent to prod server for releases.
Pushing from dev -> test is fine. But how about copying the code from test to prod? I don't want to ever push code from dev --> prod because multiple developers are working on the project and they're all at different points in the code.
I could simply scp the code over, but is there a more efficient way? Thanks all.
I found out, it's because in application.rb :
config.assets.paths << "#{Rails.root}/public"
I think the most immediate downside of Heroku is that the free tier comes with one dyno that must be booted back up after a short period of inactivity. In other words, the first user to visit your website in a while has to endure the wait until the dyno is spun back up.
Once you cough up the $35/month minimum for an extra dyno, then both dynos stay on. Just something to keep in mind when you're comparing practical price points.
@GuilhermeSimoes I took a different approach to this same feature.
In devise/registrations/new.html.erb:
link_to "Cancel registration using #{session['devise.omniauth'][:provider].titleize}", cancel_registration_path(resource)
(only if the 'devise.omniauth' session var is set)
I also switched to using 'devise.omniauth' because the devise documents say it cleans anything in the session that starts with 'devise' on successful authentication.
Great cast as always. =) Thanks Ryan.
How different would the process be if the target was a non-vagrant Ubuntu server?
How would I ago about dealing with the absence of the vagrantfile?
I am trying to build a deployment that has the fewest possible components, and it seems to me that while nginx and unicorn are necessary, vagrant is not.
Thanks!
One thing I didn't see mentioned about Rack::Cache - it should be used to set a max-age on your static assets (css and js) right?
I've set this in production.rb and it seems to work:
But I'd love to see more info on this. It seems like with rail's asset compilation, the max-age could be a year or more, since the url/filename will change with new new push. But please correct me if I'm wrong.
Is there any significant performance penalty for calling
object.class.validators_on(name).any?
(below) for every field? Would it be measurably better to move this array retrieval to the form level?Also, the snap before the delegate refactoring was awesome. Thanks Ryan!
Just a quick note:
This was a very awesome tutorial, but I fumbled around a bit with adding in the username. It worked when I manually updated the db fron the console, but it didn't work when I tried to create a new account. Needed to add this to /models/users.rb:
# Setup accessible (or protected) attributes for your model
attr_accessible :email, :username, :password, :password_confirmation
For any rookies out there like me, don't forget to add :username to this line. :-)
Ryan Bates - You rock! Worked awesome locally and on Heroku.
This is a great screencast, but I'm having an issue that I can't seem to get around.
I deployed my app, but it comes up with a 500 error every time (with my custom 500 error html page). I tried looking in the log, but it doesn't seem to be logging anything at all, so I'm at a loss to figure out what my error is.
Any ideas?
Thanks!
I found that in order for the card to process with your example, I had to put the variables in the card around
{ }
and also delimit them with a comma.Worked perfectly in my rails 3.2.2 application. Thank you!
Here's the simple_form code I used:
<%= f.input :schedule_date, :label => 'Date', :as => :string, :input_html =>{:class=>'datepicker'} %>
I changed the javascript:
application.js
$(function (){
$('.datepicker').datepicker();
});
This allowed me to use datepicker on any field where I specified :class=>'datepicker'
If you're using rails 3.2, you'll need Tom Harrison's coffee script snippet (see below) to get around a date save problem.
How did you get around the Twitter Bootstrap and Stripe issue?
I'm having issues in development mode where it's always returning an error with Invalid Token on the card. It's like it's trying to submit to Stripe with no card information.
Fantastic screencast Ryan! So many rails developers are bewildered by the deployment process or have no idea how to setup the stack from scratch.
While capistrano is indeed a great tool and allows you to maintain very complex setups, but overtime found it to overkill for simple webapps with just single production server and maybe a staging server. Having tried heroku I really think git is the way to go in this case. Setting up post–receive hook on the the server is really very simple and all your deployment boils down to running 'git push production localbranch:master'.
With regards to unicorn I really see no reason you chose it as oposed to phusion passenger. It is an extra dependency that needs to be maintained. For me the beauty of using passenger lies in the fact that I don't need to maintain a separate service and make sure it is running at all times.
Okay, good to know. I hope that server location will lose SEO significance. No idea why it keeps having influence these days. Wonder what's the reasoning behind it.
I just tried on local. No link with capistrano.
But the problem still remains.
From scratch, first compilation, it generates 3 levels of assets directory. /public/assets/assets/assets
Problem with
assets:precompile
Thanks to ryan I can deploy my app with capistrano now but evertime come the
assets:precompile
command it takes longer and longer.In fact assets subdirectories are added everytime :
app/public/assets/assets/assets/assets/assets etc .....
It looks like it compiles all assets recursively.
I thought it because I have :
config.assets.precompile += ['*.js', '*.css']
but even if without the problem shows up.Any idea ?
What's the best way to limit cacheing to only one format?
For example, I only want to cache JSON responses.
I pay €10.85 for my hetzner servers with 1024 MB RAM. They come highly recommended. They're in Germany.
Just as UP4B LLC mentioned,
rails g devise_views
is deprecated. It's nowrails g devise:views
.Source: (https://github.com/plataformatec/devise/issues/634)
We have tested yes! A resent client with heavy SEO development was ranking around bottom of page one for a number of years. With just the movement to UK server we have seen a 4 place growth with no extra SEO work done. Its a clear indication that it has an effect.
SEOMOZ still stands true with this as well if you search out there forums. But I do think It has come the day for it not to with cloud being so big now.
Guess I should've looked better :). Thanks!
You can try multistage extension, have been using that one and been happy with it.
https://github.com/capistrano/capistrano/wiki/2.x-Multistage-Extension
thx a lot
I've tried to set it up so i can deploy to both a staging and production server, but it hasn't worked out yet. Any spproach to go about it? Its basically the same set of tasks, but with a different server location. Something like cap staging:deploy and production:deploy etc.
Awesome cast tho!
you can run rake db:seeds as a remote task under Capistrano's control. See the revised screencast.
I would check the following:
1. Make sure that your target server, e.g., Linode is known to your source, e.g., GitHub server.
2. Make sure that you can follow your script manually, i.e., type in each command on the terminal and see where you get asked a password related question and try to use public/private key authentication to automate the authentication process.
That should help you isolate the problem.
I doubt that the server IP has much influence on search engine rankings these days. But I'm curious: does anyone have experience with this? Done some tests?
strangely its in a script and doesn't ask for a password... perhaps thats why?
I'd check if you aren't typing the correct deployer password.
anyone got a clue why this would happen to me?
sh -c 'cd /home/deployer/apps/appname/releases/20120324031224 && bundle exec rake RAILS_ENV=production RAILS_GROUPS=assets assets:precompile'
** [out :: 106.187.88.49] rake aborted!
** [out :: 106.187.88.49] FATAL: password authentication failed for user "deployer"
Can't figure it out to save my life. :)
It has everything. see link
Although this is a little old it still stands true.
Thanks Nico!
I know you've gotten some responses but I'll throw in my 2 cents. If you're doing this for fun only then go with whatever you enjoy or challenges you. If you're doing it for money or for recognition, determine what your competitive advantage is/could-be and if either a VPS or Heroku can help you provide your customers with an advantage choose them. If neither of those are true pick one that you trust and can use effectively. I learned a ton by building systems in VPS and on various cloud providers, but at the end of the day rails is my passion (p.s. I work for Heroku). Everyone should know something about how servers are set up, only you can choose which provider is right for you.
It depends on how much control you want over your environment. If you're not expecting your app to have to scale much, you might go with a VPS. However, if you're expecting the app to grow rapidly and for your userbase and daily record commit to increase by a large margin, you might consider a hosted solution like Heroku or EngineYard. Both of those solutions scale very well up and down.
Sorry for blowing up the board. I found the problem. One of the Twitter Bootstrap js files was conflicting with it. It is all working now.
I just had this problem, you need to set capistrano to symlink youre public/whatever directory to a shared directory of your choosing.
See the answer to this stack overflow question
http://stackoverflow.com/questions/4648180/keep-unversioned-files-when-deploying-with-capistrano
You can do a whole lot with a single dyno - and that is for free.
One dyno can serve one request at a time, that is for example 10 100ms requests/sec.
See here for more info: http://devcenter.heroku.com/articles/dynos.
You can also send mails from that one dyno, unless you send bulk mails. I recommend sending those in a background process to not block your web dyno(s). Also note that dynos drop requests that are longer than 30 secs.
A permanently running background process needs at least 1 extra dyno which is 35$/month. But if you don't need a permanent process you can programatically start a dyno when a job is added to the job queue and stop it once it's finished. That way you keep cost low, as dynos are paid per hour.
For image processing I recommend storing the images on Amazon S3 which is rather cheap, check their pricing info for details. Heroku is not suitable for storing files, as dynos are not persisted so you'd loose all uploads after dyno restarts or deploys.
Hope this helps.
What has SEO to do with server location?
I took Justin's subscriptions.js file above and converted for new user and got the same results. Works fine in development mode but is essentially ignored in production mode. Other js files are working fine. Must be something in the asset pipeline configuration. Anybody else using this in production mode?
Im using carrier wave to store uploaded files, but when I do a deploy, those files get overwritten and are not longer accessible, cause they are in previous releases...I know I could use something like a3 for file storage, but I don't really require that right now...
Any ideas on what I might be able to do copy the previous deploys "upload" dir back into the "current" app?
Thanks!
Thanks for taking the time to make these improvements, and especially to give the detailed explanatory commit messages Karel, they're really helpful.
Any reason this would not working in production mode? I know the code gets minified. I altered the code for new user but works great in development. I set break points in the deminified javascript and it is as it does not even get called. The new_user id is there in the HTML. This might be too heavy to post here but I feel it is something stupid that I missing. Thanks for any help. Here is a portion of the deminified javascript:
I don't think you will pay much more than $40.00.
Though, as you see here, if you do this on Linode, the cost will easily be halved. This is a rough estimate based on my personal experience however and I may easily be off.
I would love to use Heroku but there servers are US based and for SEO purposes my clients are all UK and UK based services.
Would be nice if Heroku could supply UK based service.
Hello,
I am interrested in Heroku as well, it seems so easy and restful. My only concern is about the price, for a small commercial web-site, let's say 200 visit a day, some mailing processing and a bit of image processing, how much will I pay.
I would be greatful to have an estimation... could you help me?
thx a lot.
Hello,
I am interrested in Heroku as well, it seems so easy and restful. My only concern is about the price, for a small commercial web-site, let's say 200 visit a day, some mailing processing and a bit of image processing, how much will I pay.
I would be greatful to have an estimation... could you help me?
thx a lot.
I might be asking too much but where should seeds be run?
In Europe we smile about the pricing of VPS and RootServers Hosting's in USA ...
Linode: 512mb, 20Gb, 200Gb Traffice => $19.95
Hetzner: 512mb, 20Gb, 1Tb Traffic => €7.90
Heroku..unpayable..
When you work with clients you def. also need an Adminplatform for them to install their own email accounts etc..
Anyway thanks for this screencast..and all the others. So helpful.
Werner
Great job Ryan. Question: what if you're deploying to a test server first, then up to production? like so: Dev --> Test <--> Prod. The arrow goes both ways between test and prod because the prod database is sent to testing db and the testing code sent to prod server for releases.
Pushing from dev -> test is fine. But how about copying the code from test to prod? I don't want to ever push code from dev --> prod because multiple developers are working on the project and they're all at different points in the code.
I could simply scp the code over, but is there a more efficient way? Thanks all.
+1