When I was developing my Rails app I noticed that it got extremely slow as soon as I included some background File creation via Amazon S3.
When I uploaded my site to Heroku the load time dropped a lot.
On my local server a page load takes about ~12s, on Heroku just ~1s.
Why does my app run that much slower on my local computer?
Does the Heroku server have a faster connection to the Amazon S3 servers?
To answer to your last question, yes, Heroku almost certainly has a faster connection to the AWS servers. According to the Heroku support page:
Heroku’s physical infrastructure is hosted and managed within Amazon’s secure data centers and utilize the Amazon Web Service (AWS) technology
Since they are both physically near and probably use the same datacenters as Amazon, any uploading / downloading to Amazon servers will be fast.
EDIT:
And as #Stefan noted, running rails in production mode speeds up a lot of stuff, including assets serving. You can try to run your server locally in production mode to see if that's the issue by running
$ rails s -e production
Related
I want to know how to build a rails server and host an app on it locally. I know I can use heroku or aws but in the case of this app I can’t, the database should be hosted locally in the company for security reasons; they do not want to store their data on servers that are not theirs.
How do I start?
What are the main things to consider?
Do I host on heroku and link the local database to the site or do I host them all in the same place?
How much power does the machine need for around 10-20k users?
What OS should I use Ubuntu or what?
Would really appreciate if you have any tutorials or article links.
You can just use ngrok. It doesn't require any side server deployments.
When I enter a URL into my browser, and it sends a request to the server (in this case, the host is salty-headland-18854.herokuapp.com), are all my Rails files stored at this host?
How does Puma come into play? I understand Puma to be a web server and I've included its gem. What is the distinction here between the host and Puma?
Does Heroku have a bunch of physical computers somewhere, that house my literal .rb files?
Visual of my question
It depends on the files, but pretty much the answer is yes. Heroku pulls down your app from the git repository specified (or you push it to Heroku's git repository) and Heroku has all the files from that. Without a security exploit, no one is able to access their source.
You can think of a Heroku Dyno as a Linux server with the complete Rails application. When it is launched for the first time, a linux server is built and the Rails application copied to it and the app server launched.
You code actually lives in the Github repository you have linked to Heroku. Persistant data is stored either in the database or an external file service such as S3.
It is possible to run commands on the Dynos using heroku run
Reference
I have an app running locally on Ruby on Rails, and nginx is my assets server. I have node server running for the real time stuff. The js file that runs with node is in the rails application folder. Redis subcription is used for the intermediate store between node and rails. So, it lies in the js file. It is subscribing the data from sql server trigger action. Redis Server is running as a service.
With this brief scenario, do any of you have rough idea, how I can go about deploying an app with all these in heroku?
Any opinion is highly appreciated.
Regards,
Sagar
Considering migrating an app to Heroku. Currently we build & test locally before deploying to our own server for hosting...But the application is growing and now wondering if it's reasonable to have, say, 3 versions of our app. One local to developer's machines. A second (testing) deployed via Capistrano to an internal server. And then finally a third on Heroku (production). Databases would not need to be shared.
Any problems or advice for this sort of scenario?
I think it's a good thing to have a staging server with the same environment as your production. So instead of internal server, wouldn't it be better to test on heroku?
For this purpose I've created another app on heroku and before updating my production app, I push my app to the staging one.
I would highly recommend the heroku_san gem which simplifies pushing app to heroku to just rake staging deploy.
I do this. I have development on developer's machines, staging, and production.
Staging is our test sandbox and sometimes also shares user databases with production so I can let users beta test, etc.
Whether or not you use Heroku for production really doesn't matter does it?
I have been testing an app and have all of the functionality worked out. Being my first go with ror I have a few questions about my next step; grateful for direction on this.
Should I do all of the design and UI before putting my app online, or after?
In trying to research this I have found three things that keep coming up as great tools to help deploy - Heroku, Capistrano, and Phusion Passenger. I know Heroku let's you deploy quickly and easily, but is this the option if I want my app at it's own URL? I currently host other websites (Wordpress) at Hostmonster, but they aren't supporting Rails 3 yet.
What is the difference between the functionality of Passenger and Capistrano? I have been searching, but not knowing some of the terminology, I'm not sure how to decipher all of it.
Go with Heroku — there's no need to clutter your brain with all of the hosting stuff since you don't already know it. Heroku is great, and you can easily have your own domain name. Point your nameservers to a.ns.zerigo.net and b.ns.zerigo.net and run…
heroku addons:add zerigo_dns
heroku domains:add example.com
heroku domains:add www.example.com
Set your domain's DNS servers to a.ns.zerigo.net and b.ns.zerigo.net.
And done deal, you're ready to deploy on Heroku. Your first dyno (app instance) is free, Zerigo's basic dns is free. You're rolling with 2TB/bandwidth (soft limit) and a whole lotta request-serving for a grand total of $0 and 15 minutes.
And for deployment, from start to finish here (provided you develop within the limitations of Heroku's platform [ie. read-only filesystem, PostgreSQL, bundler-dependent]):
heroku create yourapp
git push heroku master
heroku open # opens yourapp.herokuapp.com in your default browser
If you need to configure your DNS records:
heroku addons:open zerigo_dns
It's like magic, but it's all just solid engineering.
And to be clear, I don't work for Heroku.
Whether to finish your UI designing before going live is a decision you have to make. I don't think this will have any rails - deployment related consequences. So if you want to deploy and release fast in a rapid manner, go ahead.
You should be able to use your own domain name even if you are hosting with heroku. Take a look at this
Capistrano lets you deploy your apps with ease. So you don't have to login to your remote server and pull code from git, restart services...etc etc. You can just run cap deploy from your workstation and everything will be deployed on your server and all services will be restarted..etc.
While passenger is something like mod_php. It hosts your application. It works with apache or nginx. You will most probably end up using both capistrano and passenger. I don't think they are comparable because they do two different things.