Does Ruby on Rails scale? Yes, it does, and it does very well.
To be more specific: Yes, it does. If someone told you it doesn’t scale, they haven’t been through the trenches. Those benchmarks you’re looking at are very skewed, too.
The whole idea that “Rails doesn’t scale” admittedly started before my time with Rails, but it carries over today, though with little weight.
These days, everyone’s into benchmarking things. They’ll benchmark TodoMVC across different languages and frameworks and look at the numbers and say “ok clearly doesn’t scale”
And they’re right. Of course it doesn’t scale: SQLite running on Webrick, no caching, no tuning… it’s just a recipe for disaster. Have you ever seen SQLite in production? Webrick? If you have, I send my regards.
Maybe they benchmarked Puma’s defaults and PostgreSQL, and said it still didn’t scale. That’s still inaccurate.
There’s no one-liner to configure a scalable Rails application, or any application really. Everyone’s setup is different. Everyone’s application is different, and has different needs. Shopify has different needs than GitHub. 500px has different needs than BaseCamp.
I scaled an Alexa Top 5000 site on a single VPS that costs $48/month: 4 cores @ 3GHz, 4GB ram. This node handled Nginx, Puma (3 workers, 128 threads), Redis, PostgreSQL, and Sidekiq. Yes, I absolutely love my monoliths. The metrics were as follows:
- 394k PostgreSQL reads/minute,
- 62k PostgreSQL writes/minute,
- 577k requests/minute
- Average response time: 48.7ms
This was sitting happily at 62% CPU, using 2.8GB of RAM.
Let me assure you that this wasn’t TodoMVC. It’s one of the more complex applications that I’ve seen to date. Getting everything to that point took no more than an hour and required a mere 45 lines of code.
I won’t go into too many details as to how I did it because that’s not my point here (and that’s for another article). My point is that those who say Rails doesn’t scale is using the wrong tool for the job. No, Ruby isn’t going to mine a blockchain any more productively than writing a web framework in C++ is (save for OkCupid).
Because you don’t scale Rails. You scale an application stack. You scale it by scaling your services, like HTTP services such as Nginx; tuning databases like PostgreSQL and MySQL, implementing server-side caching with Memcached or Redis, increasing available CPU/RAM/disk, eliminating N+1s and plugging memory leaks.
Yes, the defaults aren’t going to scale. And if you expect them to, you’re in the wrong industry.