The original idea behind the use of Node.js was to build websites with real-time push capability. Unlike the standard client/server model where a request is made and the client has to wait for a response - very uni-directional as illustrated below, it became possible to develop two-way connection web applications (websites) with free data exchange on a continous bases.
What is a WebSocket?A WebSocket is a computer communications protocol, a system of rules that allow two or more devices to exchange information and data. The well known internet standards http and https are also communications protocols which send and receive information via requests and responses as already mentioned above. A protocol defines the rules, language, semantics and rate of synchronization of the exchange of info. It may also include details of and possible error recovery methods.
Why use Node.js as your backend?
Node.js is a perfect choice for data-intensive, real-time apps that run across distributed devices. Take chats, as an example. With Node.js, you can easily serve multiple users and devices, and handle both big traffic and intensive data exchange. Speaking of data - it is also possible to leverage the fact that HTTP requests & responses are essentially data streams, and stream large files or even process them while they are being uploaded (to encode audio & video, for example). It is also a powerful solution for collecting and visualising real-time data in the form of advanced dashboards. GraphQL is an interesting example. Although this query language for APIs can work together with other programming languages, such as Python or Java, it’s Node.js that helped GraphQL to gain traction.
No matter the common uses of Node.js, it is also worth to keep in mind that there is a robust and helpful community behind it. It makes it much easier to solve any problem at hand - not to mention that Node package manager (npm), which is included in Node.js by default, is said to be the fastest growing and one of the largest ecosystem of open source libraries in the world. Node.js also comes with fine documentation.
On the other hand, Node.js is not the best choice for handling CPU-intensive apps. Take editing graphics as an example - it requires an efficiency that an event-based and a single-threaded environment can’t really provide. Itis also being criticised for not being mature enough - at least not just yet. Even though the main Node.js modules are stable, there are many entries in the npm registry which are low-quality or just haven’t been tested and/or documented properly. The examples of Node.js applications Despite a few drawbacks, the words that best describe Node.js by its users happen to be: fast, simple, and easy - but also powerful and flexible. It might be the reason why Node.js is widely used by both emerging startups and some well-known companies.
Rumour has it that Netflix and PayPal have already implemented Node.js, and saw significant results afterwards - both economically and in performance. Actually, Node.js is said to boost business productivity by the majority of companies that decided to take advantage of it. It also powers the two biggest online marketplaces - eBay and AliExpress (and Amazon on top of that). While there’s still some debate about the maturity of Node.js, its popularity is still growing. In fact, it was downloaded more than 360 million times in 2018 - and all versions of Node.js show a 40% year-by-year growth of downloads. Given these numbers, it’s likely that there will be more great Node.js examples in the future as well. Especially since Node.js is scalable and relatively easy to learn and use, which often matters for startups.