How to Improve Rails Application Performance on Heroku
blog.bignerdranch.com
blog.bignerdranch.com
Last week I finally bit the bullet and bought a VPS from DigitalOcean and installed the bits and kibbles needed for Rails apps. Specifically Nginx and Passenger. Was it easy? No - but now I have total control over my machine, and my app (which let's face it, will probably never need to scale for millions of users at a time) is in my complete control.
Heroku doesn't even have a local filesystem, what's up with that?
===
"Hi Sergio - Thanks for the note and glad you like action.io.
Please keep in mind however that Action.IO is not a hosting platform - we are a cloud development platform that works with hosting providers such as Heroku, AppFog, EngineYard or Google App Engine.
You can read more about how you can deploy to Heroku from Action.IO here: http://help.action.io/customer/portal/articles/1011326-deplo...
===
So like you said, someone fills in this hole, and a lot of people would love pay for it. I don't need to add even MORE services for something as simple as file storage for uploads.
I haven't tried it, but Cloud66 is another provider in this middle ground (they don't host, but provide you the devops tools to do so on amazon, digital ocean, etc.).
"I used to love Heroku but it's just too darn rigid. I hate the fact that everything is done behind the velvet curtain and I'm just assured it's "going smoothly"."
I've admired their marketing and infrastructure, but have never been a fan of heroku specifically, precisely because of the "everything behind a curtain". But I felt that on day one - I never "used to love" Heroku.
I wish Heroku would add static file storage to their roster.
This article seems to suggest that the number of Dyno's required for more load scales linearly with load but, as Heroku now admits, the routing is random and therefore scales much less efficiently.
I found this great simulator that someone put together to demonstrate the issue http://ukautz.github.com/pages/routing-simulator.html
If I'm using it correctly, in his first example using 82 dynos would actually result in requests taking over 9000ms. It takes about 150 nodes to get the average wait times down to around 600ms.
Parameters used:
1. Nodes 82
2. Process/Node 1
3. Requests/second: 338 (20300/60)
4. Duration request min/max 243
5. Timeout 100000
6. Time multiplier 2.00 (not exactly sure what this does)
Using multiple threads per dyno does help considerably. I guess it's equivalent to multiplying your whole dyno pool as well as having intelligent routing within the dyno itself, but problems still crop up if you have slightly inconsistent request times.Also, one problem that seems to be overlooked is the possibility that multithreading within the dyno itself is less efficient than threading across many dynos since the threads may have to compete for resources. I can imagine that performance may drop across Heroku's platform as a whole as customers switch to threaded application servers and reduce their Dyno counts.
I use it to crash my own hobby playground regularly. A simple Flask app (Python) I wrote can handle ~120 req/sec before it biffs it hard (all linked back to db connections allowed on the free Heroku plan.)
As for unicorn, unless your application is a real memory hog it should be possible to run 2 workers, which is a big improvement over using thin. But this is now the standard advice being given by Heroku, so there's not much new here.
If your app takes up 256MB, does that mean you can only fit 2 workers? Shouldn't there be some savings due to copy-on-write?