Yesterday I visited old collage of mine who is working with his team at little startup called ViaEmail. Like a lot of startups out-there he is using Heroku for his hosting platform of choice. Beginner on low-budget, but moving fast. After giving me nice demonstration I really wanted to help out this guy with some nice and useful tips. There are some of them.
Your app is "sleeping"?
If you don't have any request to your Heroku instance it will go to "idle". Because of the nature how Heroku works, the app will be feeling really slow and sluggish. There are few ways that can solve this.
One way is to scale your dynos, to at least 2. Simple. But you have to pay for extra dyno.
Second way - and probably the cheapest - is to create another Heroku instance and put a simple script that would periodical trigger requests to your app. This will prevent your app from going into idle.
I wrote a little Ruby app that does exactly that. Its called dontdieonme. To use it; create new Heroku instance, and push this code to it. Set environment variable
URL_TO_GET and I also suggest that you add add Rollbar to project so that you can see if there is something wrong. Restart the instance. The app will trigger request every 2 minutes.
- Update. Miha Rekar also proposed 3rd way. Add NewRelic to your Heroku instance and configure availability monitoring. NewRelic will ping your app every 10 minutes or so.
You are serving static assets from Heroku?
Since manually compiling assets and moving them to cloud is a bit painful you can either automate the process with Rake script that looks something like this or you can use asset_async gem. When using asset_async when you deploy your code to Heroku it will automatically compile all your assets and sync them with your cloud. Nice and easy.
Should we write tests?
The third tip that I gave was more an answer than actual tip. The question was; do you code with TDD principles, do you write test for everything?
My answer was quite simple. If you are new to Rails, new to Ruby. Don't. First learn as much as you can to be comfortable around new "world". Get to know everything, try it out, learn by doing mistakes, try to debug the thing. Then - and only then - try to improve and extend your skills by writing test. Proper test should test the right things, the right way and by slowing down the test suit as less as possible. Writing tests properly also takes time in startup world - time next to team is everything.
Hope that this tips can also save you some initial headaches. If not - let me know if I can help you out. :)