For a hybrid mobile app serving real-time updates, can I use Ruby on Rails for the API or do I need a more powerful concurrency-ready back-end system like Node.js or Scala (with Akka)?
-
It's a location-based app that needs to provide users with real-time information about the location of people nearby. I'm looking to avoid building native iOS + Android apps by using a service like to build a hybrid version with Javascript/HTML/CSS that can serve information via a central backend API. I am most comfortable in Rails, but I'm wondering if the performance requirements of this will app will require switching to Node.js or Scala (with Akka) for the back-end API, given the app needs to serve real-time information about the map location of users relative to one another. Switching away from Rails will be a costly decision, and I need to know if the faster performance justifies the switch for a hybrid mobile app. i.e. what kind of performance difference are we looking at?
-
Answer:
Realtime services need to keep lots of long living connections (so that when there's a new event at the server side, the server can push it immediately to the client side), while Rails is designed for one shot traditional request-response, so Rails is naturally not designed for realtime services. You can try http://xitrum-framework.github.io/xitrum/ Scala web framework. Some of its advantages: It's designed by a former Rails developer. Its APIs are very familiar to Rails developers. It has builtin support for https://github.com/sockjs/sockjs-client. This may be what you really need to support older mobile devices that don't has WebSocket support. As far as I know, up to this moment Xitrum is the only Scala web framework that has builtin support for SockJS. It's based directly on Netty (see http://www.techempower.com/benchmarks/ and http://netty.io/testimonials) and Akka which are very fast. Unlike Rails, Netty is designed for keeping lots of long living connections. It has builtin support for scaling your server side to multiple servers (forming a cluster of servers). With the same SockJS solution based on Node.js, to scale to multiple servers, you'll need to setup an additional Redis server, your architecture will soon become a mess and hard to maintain if you're not careful.
Ngoc Dao at Quora Visit the source
Other answers
Disclaimer: I work for Typesafe, and contribute to Play Framework every so often. The tech benchmarks for a number of websites are here: http://www.techempower.com/benchmarks/ For JSON serialization: play-scala-anorm: 176,265 rails: 71,260 Bear in mind that Techempower is a benchmarking tool that is focused on very small tasks. You may want to verify this with your own benchmarks, and see how many concurrent users you expect -- it may be that Rails works perfectly well with your userbase. Historically, certainly Rails has had issues. I can't speak to Rails now, but I can tell you my experience. I started as a Java programmer, and worked for three years doing Ruby on Rails. I learned Scala because I was seeing numbers out of Rails that I knew weren't matching the numbers I had been getting in Java. I knew of at least two companies that wrote chat applications in Rails and ended up rewriting them in Java because they weren't getting the responsiveness they needed. Again, please verify this independently. There is a sample application called Reactive Maps that uses Play with a reactive (i.e. async non-blocking) system that may give you an idea of what you can do: https://typesafe.com/activator/template/reactive-maps Play's rendering is conceptually very close to the Rails Routes / Controller / Template Views model, but it does not have a hardcoded ORM like ActiveRecord. You can use Anorm, but using a JDBC driver will take you straight back to blocking again. Many Play users use non-blocking connections against Redis / Cassandra / etc. or use a non-blocking database driver like https://github.com/mauricio/postgresql-async. You can test out a Play application with a load testing tool called Gatling: http://gatling-tool.org
Will Sargent
Related Q & A:
- How can I use real time social data from Datasift and perform real time analytics on it?Best solution by Quora
- Can I use Yahoo Stat Tracker on Windows Mobile?Best solution by Yahoo! Answers
- Can I use a t-mobile Sim with an att phone?Best solution by Yahoo! Answers
- Can I use my mobile phone as a webcam for MSN?Best solution by android.appstorm.net
- Can I use a t-mobile contract phone on a prepaid plan?Best solution by Yahoo! Answers
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.