It seems like every month, if not every week, we hear another great success story about how Node.js transformed someone’s life–and by someone we mean some major corporation with massive infrastructure and huge budgets.
Just a few we’ve encountered over the few months include:
- PayPal migrated from JSP/Java to a platform centered on Node.js, resulting in a 35% decrease in load times, or 200ms faster.
- WalMart Labs (the technology arm of WalMart) deployed Node.js for Black Friday 2013, and had zero outages while seeing CPU utilization hover around one percent.
- Groupon replaced their Ruby on Rails platform with Node.js, resulting in a 50% reduction in page load times.
- LinkedIn reduced server resources by 90%, and performance by up to 20x in some cases.
- Yahoo uses Node.js to serve up to 2M page loads a minute.
So with all that said, is Node.js the right choice for you?
Why is Node.js faster?
Node.js is considered a non-blocking, asynchronous I/O platform, as opposed to traditional web-based scripting languages like Python, Ruby, or PHP. Essentially, this means that events, unless otherwise directed, happen in parallel. There’s nothing magical about Javascript or Node.js, other than the simple fact that each request won’t wait around for the previous request to finish unless explicitly told to do so.
The result is, you can have one request processing in the background, or in fact, dozens of requests processing. In traditional scripting languages like Python, each request will get handled sequentially unless you take special measures to handle them asynchronously. And even then, the logistics of rounding up all the asynchronous request responses and wrapping them in a nice, tidy package to return to the user is not trivial, although there are certainly software libraries that attempt to make these traditional scripting languages perform more like Node.js.
Should you always use Node.js?
That’s a really good question, and to provide an adequate answer, we first look at the application requirements and determine if Node.js is the right solution.
Pros of using Node.js
- Great performance
- Particularly kind to battery life on mobile and tablet devices
- One common development team for building front-end and back-end portions of your web application, rather than segmented teams
- It’s the new sexy choice for a lot of advanced developers
- Much lighter impact on server resources, allowing for greater scalability
Cons of using Node.js
- Node.js is a paradigm shift for Python/Ruby/PHP developers
- Lack of mature frameworks for Node.js
- “Rapid development” not quite as rapid with Node.js
- Development costs to implement a Minimum Viable Product (MVP) is often higher
- Not well-suited for specialized applications (i.e. scientific computing)
- Not well-suited for real-time applications (for that matter, neither is Python, PHP, or Ruby)
- Not as many third party libraries and a lack of support for Node.js compared to other languages
- Lack of Object-Relational Mapping (ORM) solutions for database management (although this is constantly evolving)
- Still bottlenecked by other systems like databases (i.e. a slow query will still be slow, whether it’s called by Node.js or Python)
To Node.js or not to Node.js, that is the question
For our clients, we typically start by analyzing their needs, and answering the following questions:
- Is this a mobile-heavy application or just a simple website, or somewhere in-between?
- Is this a Minimum Viable Product (MVP)?
- How much does the client expect their business model or product to change over the course of the next six months, year, or two years?
- What timeframe constraints does the client have, and how quickly do they need to deploy to meet their marketing window?
- What is the client’s budget?
- How would the client rank the following three factors: performance, cost, and time to market?
- How many customers does the client expect to serve with their application?
If the client is building a mobile application or an application with very static requirements and huge performance concerns, Node.js makes a lot of sense.
When Node.js Makes Sense
In the Node.js success stories above, all of these companies were leveraging Node.js to either (1) handle huge performance needs, or (2) create very mobile-centric solutions. WalMart Labs was concerned about serving customers during peak periods like Black Friday, while LinkedIn and Groupon were concerned about being able to provide mobile-centric technology to their clients.
They were also rewriting mature portions of their infrastructure with very little feature changes, meaning the requirements were very static and not subject to major changes or pivots in functionality.
In our experience, we have clients who need to build a MVP at the lowest cost possible. They know the product they are building now will be quite a bit different from the product they build two years from now. Their requirements are fairly volatile, and need to be validated with feedback from their customer base, hopefully in the form of a prototype or a MVP.
Conclusion
While we actively embrace Node.js as a solution for many of our clients, we also recognize that Node.js is not for every project. Because of this, we still regularly employ solutions like Python/Django and PHP (Yii, CodeIgniter, WordPress) for many of our projects.
That said, the world of Node.js is constantly evolving, and as Node.js matures, more and more people will leverage its benefits while the negatives become extinct.
Nonetheless, you should look for a technology partner who can really understand your needs, and match your product and vision with a technology that supports your technology needs, budget, and future growth.
We’d love to discuss your needs with you, so feel free to reach out to us for a free consultation.