I am developing a site using Ruby on Rails. I would like to develop the REST API (JSON) separately to maximize performance, the Rails stack just takes away too much.
Are there any performance benchmarks out there? What do you think would yield the best performance? I am currently thinking about the following, because that’s what I have experience with. Is there anything else I should consider? It should be lightweight.
- node.js
- Scala Spray (http://spray.io/)
- Ruby Sinatra
Thanks!
Summary: Maximize your performance as a developer. Use stack you know best. First make it work, then make it fast.
There are all kinds of benchmarks out there. Let’s say, node.js can handle 100k HPS (helloworlds per second) and Sinatra can only do 80k. What does it tell you? Nothing.
Also, sometimes higher performance comes at a great cost. Take ruby C extensions, for example. Sure, C runs faster than Ruby, but it prevents other threads from running on other cores (because of GIL).
So, don’t choose tech only by benchmark figures from the internet. There are so many factors to consider besides raw HPS number.
LINK: If you think Rails is too heavy, you should try rails-api. It’s basically a stripped down version of Rails (you don’t need things like cookie authentication or MSIE rendering helpers in an api server).
Personal story
I run an API server that handles some load. First version was written with Rails. Then I thought “Hey, Rails Is Bloated (c), let’s rewrite everything with Sinatra”. And then I had waves of frustration coming one after another. It turned out that Rails does a lot of small but helpful things which I didn’t appreciate. I gave up, rewrote it with Rails again (applying lessons learned) and lived happily ever since.