What Happened Before Node.js?
If you coded a client/server web app before Node.js, then you know they were written in a way where the client demanded resources from the server, and the server would respond with what was requested. This led to the server only responding when there were client requests, and connections would be closed after each response.
With databases becoming bigger and bigger, this approach wouldn’t work very well. For instance, if you wanted to Tweet, your client would request the server, and the server would respond—but when you have millions of concurrent users, it would cause wait times. Needing to wait 10 minutes for the server to have resources to handle your request is not ideal.
This is where Threads would come in. They’re a way that systems have to run concurrent operations. A new request opens a new thread, and said thread has everything the request requires to run to completion. But with millions of users, you’d have to create millions of threads. If you used a Ruby on rails server, it would sit there until the file system did whatever it is you asked of it.
Unlike with older client/server models, Node uses the idle time of when the system is too busy to handle other requests. When the file system is finished with its task, it tells Node to come collect the requested resources and sends them to the client browser.
In its simplest form, Node.js is essentially event handlers that are called when Node events happen. This makes if much faster than multi-thread systems, all without needing those extra threads. However, this also means that Node isn’t really good at handling operations that consume CPU, since CPU-intensive requests overload the only main thread it has. If you’re using Node, it’s smart to avoid these types of operations so you can leave your main thread free.
What’s the Biggest Advantage of Node. js?
Node. js Frameworks and Tools
Because Node is a low-level platform, a lot of it depends on the libraries available. Luckily, the community is pretty active (and growing).
Some of the best frameworks worth learning are:
hapi: Originally built to handle the massive scale of Walmart’s Black Friday, hapi is a framework for building applications and services. Developers can focus on reusable application logic rather than building infrastructure.
AdonisJs: One of the fastest Node.js web frameworks, AdonisJs is a full-stack framework focused on the developer’s business needs over finalizing which package to choose.Meteor: Another full-stack JS platform for web and mobile applications. It integrates with frontend libs such as React, Vue, and Angular.
Express: Minimalistic and focused, Express gives you one of the simplest, yet powerful ways to create web servers.
koa: koa is even simpler and smaller than Express. If you’re using Express and run into incompatible changes, then you’ll love joa, since it was born out of the need to create such changes without disrupting the existing community.
Fastify: Another incredibly fast Node.js web framework, Fastify is focused on providing your devs with the best experience while removing overhead and giving them a powerful plugin architecture.
Nest.Js: A RET API framework, Nest.Js is flexible and versatile. Build efficient and scalable server-side apps, and combine Object Oriented Programming with Functional Programming and Functional Reactive Programming. Internally, it relies on Express, but provides compatibility with many other libraries.
Related Blog Posts
[hcode_blog hcode_post_per_page=”3″ hcode_show_post_title=”1″ hcode_show_thumbnail=”1″ hcode_show_post_feature_image=”1″ hcode_show_excerpt=”0″ hcode_show_content=”0″ hcode_show_continue_button=”1″ hcode_categories_list=”office-365″]