I gathered the following information from all of the homework I’ve been doing over the previous few days. Node.js
Some of the resources I’ve found include:
Given that Node.js can be used practically immediately on Amazon’s EC2 instances, I’m trying to figure out what kind of situations require Node.js rather than any of the other powerful kings like PHP, Python, or Ruby. I understand that it relies on one’s linguistic skill, but my question is more general in nature: When should a certain framework be used, and for what kind of problems is it best suited?
Asked by Legend
Using the “long-polling” technique, you can create an application that transmits real-time updates to the user. Long polling on many of the web’s behemoths, such as Ruby on Rails or Django, would put a tremendous amount of strain on the server, as each active client consumes one server process. This is the equivalent of a tarpit attack. When you use Node.js, the server doesn’t need to keep track of many threads for each open connection.
This implies you can use Node.js to build a browser-based chat application that uses almost minimal system resources while serving a large number of customers. Node.js is an excellent choice for this type of long-polling.
I’m excited to see what other people have to say about this question; it’s a great one.
It’s also worth noting that Node.js is ideal for instances where you’ll be reusing a lot of code between client and server. The Meteor framework makes this very simple, and many people believe this is the way web development will go in the future. I can tell you from personal experience that writing code in Meteor is a lot of fun, and a huge part of it is spending less time thinking about how you’re going to arrange your data so that the code running in the browser can simply change it and feed it back.
TicTacToe and Long Polling with Pyramid is an article about Pyramid and long polling, which turns out to be quite simple to set up with the help of gevent.
Answered by Benson
Node.js, in my opinion, is most suited for real-time applications such as online games, collaboration tools, chat rooms, or anything else where what one user (or robot? or sensor?) interacts with the program needs to be viewed by other users right away, without requiring a page refresh.
I should also point out that using Socket.IO in conjunction with Node.js will minimize your real-time latency even more than long polling will. In the worst-case scenario, Socket.IO will revert to long polling and instead use web sockets or even Flash if they are available.
But I should also highlight that Node.js can handle almost every case where the code can become stuck due to threads. Or any other case in which an event-driven application is required.
In addition, Ryan Dahl stated in a conference I previously attended that the Node.js benchmarks are very close to those of Nginx for standard HTTP requests. So, if we develop with Node.js, we can effectively provide our standard resources, and when we need event-driven functionality, it’s ready to handle it.
Answered by fisherwebdev
NodeJS is useful for a variety of reasons.
Reasons to avoid using NodeJS include:
I like NodeJS because it’s quick, wild, and fun, but I’m afraid that it doesn’t care much about proved accuracy. Let’s hope we can combine the best of both worlds in the future. I’m interested to see what will eventually replace Node…:)
Answered by joeytwiddle
To cut to the chase:
Node.js is well suited for applications that have a lot of concurrent connections and each request only needs very few CPU cycles, because the event loop (with all the other clients) is blocked during execution of a function.
Mixu’s tech blog has a fantastic post about the Node.js event loop: Understanding the Node.js Event Loop.
Answered by stewe
I’ve used Node.js in one real-world application. One of my clients requested a simple static HTML website from the company where I work. This website is for selling a single item via PayPal, and the client also requested a counter to display the number of products sold. The client anticipated a large number of visitors to this website. I chose Node.js and the Express.js framework to create the counter.
The Node.js program was straightforward. Get the amount of sold products from a Redis database, increment the counter when an item is sold, then deliver the counter value to users using the API.
Some of the reasons I picked Node.js in this scenario
Node.js was an excellent choice in this scenario.
Answered by Joonas
Post is based on https://stackoverflow.com/questions/5062614/how-to-decide-when-to-use-node-js