use a nodejs web server to serve a full rails application
I and 4 colleagues will start on a university project and decided to use Ruby on Rails as it has many libraries that we need and is joyful.
The project is a website for researchers which will allow them to create account,login/logout,post their researches.
The project must feature hash tags and researches can be linked together, visitors must be able to search by tags and see the related researches, we may use a knowledge base to serve this knowledge to people.
So to my problem : performance, it is mentioned in the project paper that we should have good performance.
I've heard about Rails reputation of not having very good performance compared to others(Not sure if this has changed though but...).
I was thinking to use nodejs because it's very fast and scalable but unfortunately I didn't find all the libraries we need.
I searched and searched for a way to use a nodejs web server(expressjs or anything) only for serving and writing the whole application with Rails but I didn't find a way to execute ruby on nodejs.
So how to accomplish this ? If I use Nginx as a proxy server, can I then use nodejs as the main server(and If I can how?).
Thanks in advance.
PS
Thought to mention that we'll use use the latest versions of Ruby,RoR.
As for Node.js we don't mind to use 5 or 4 as long as our goal is achieved.
Scaling a web application is more about good architecture and best practices than it is about the web framework / language.
RoR has a bad reputation for performance coming from the early days when Twitter decided to switch to Scala. Actually they only switched some heavy duty processes for the back-end in Scala and take advantage of RoR's features for the rest.
Chances are that your application will not be scaling as much as Twitter. Even if you are going to, you should use an approach similar to theirs:
Apart from Twitter, other large-scale sites that use RoR are Github, AirBnB, Basecamp, Hulu, Shopify and many more.
Conclusion: So my point is, RoR performs well enough that chances are that you don't need to be worrying about performance. Use it because it is fun to write and has the libraries you need, and worry about scaling when and IF it is needed.
Also, sorry to disappoint you, but running RoR on NodeJs is not possible, NodeJs is server-side Javascript, so it can't run Ruby. Alternatively you could run RoR on a JVM with JRuby but that is another story. If I were you I would stick to Ruby web servers like Passenger and Unicorn.
I would recommend you to use Nginx as a load balancer and for caching for your rails app, otherwise write your app in JavaScript, my hones opinion. NodeJS is a server side JavaScript and it's not possible to run ruby apps with node. Ruby is slower than NodeJS, just make a simple test with loops and strings, you'll see a major difference.
In Javascrip with 10 mio iterations you'll see results under a second and sometimes nearly a half a second.
var str = 'blab lablaejd ksjdhsdlnsdsdksdkfnvdfvjeefvkdnfvkjfvidfvjndfvnfvfvovhelloasdkjfiweefsdffh';
var newstring;
var start, end,i;
start = new Date().getTime() / 1000;
for(i = 0; i<10000000; i++) {
var index = str.indexOf("hello");
newstring = str.slice(index, index+5);
}
console.log(newstring);
end = new Date().getTime() / 1000;
console.log(end-start);
document.getElementById("str").innerHTML = newstring;
document.getElementById("time").innerHTML = end-start;
<p id="str"></p>
<p id="time"></p>
链接地址: http://www.djcxy.com/p/64670.html