Welcome to Node.js Tutorial – Following these lucid tutorials helps you learn basic understanding of Node.js. With the progression of your learning, more advanced concepts to program and build server side applications and networking applications are provided.
An introduction to Node.js
Node.js if free to use and is an open source server framework. Node.js runs on various platforms and some of them are Linux, Unix, Windows, Mac OS X, etc.
- Non-blocking I/O model
To appreciate the features of Node.js and how it revolutionized the server side applications in terms of resource usage and event handling, we might need to take a sneak peak into the traditional model of web servers. And know how Node.js fill the performance voids.
In a traditional web server, when a web-client (browser or an application) makes a request, server takes the request and waits for the response to be prepared by file system/database/any other resource. Consider that your web service has become popular and number of web-client requests hitting the server is increasing day by day. But if you observe, the server is serving one request at a time and while the file-system/database is preparing the response, the server is being idle, instead of taking requests from other customers. Node.js exploits this idle time with its event-driven framework. That is after taking a request, the server tries to prepare the response. And if there is any resource (file-system/database/etc) involved to prepare the response, server is let free and is informed through events when the response is ready. Mean while, instead of being idle during this time, server takes requests from other clients. When a response for a client is ready, an event is generated to let the server know the response is ready, which is in turn served to clients.
Programming Node.js Applications
Following are some of the capabilities of Node.js:
- Node.js can dynamically generate content and present it to web clients
- Node.js can do file operations like read, write, update, delete, etc.
- Node.js can collect data from clients through forms.
- Node.js can connect to various databases like MySQL, MongoDB, etc., and perform respective DB operations.
- Node.js has builtin JSON module to work with JSON files.
Node.js Production Ready
Currently Node.js v8.x is the latest Long Term Supported version. So, most of the examples you come across in this tutorial are tried out on Node.js v8.x.
Node.js Use Cases
Following are some of the notable use cases that can take advantage of the Node.js Event driven model.
- Low latency provided by Node.js makes it suitable for Real-time applications like instant messaging, online-gaming and collaborative applications like Google Docs etc.
- Doing tasks asynchronously makes Node.js scale for a much higher traffic.
- Node.js can scale horizontally using its cluster mode. So, if you are looking for a scalable web application, Node.js is there.
Following are some of the limitations of Node.js
- Node.js is not a good choice for applications that do heavy computation. This is because incoming requests are blocked during computation tasks that take relatively long time.
- Security provided by many of npm packages are not promising, even though core Node.js is quite stable. You may have to depend on third party tools to evaluate a package for any known vulnerabilities before using it in your application.
Node.js Tutorial Index
Following is the list of tutorials that are well explained with simplified examples to learn Node.js easily.
Node.js can be installed in your local machine and you can get started with Node.js Application development.
Modules are reusable parts of code that usually export specific objects to be used in your Node.js programs. Node.js provides many builtin modules. You may also create your own module or extend a builtin module, or override some of the functionalities of the module. We shall learn in detail.
Node.js HTTP Module
Node.js FS (File System)
To handle file operations like creating, reading, deleting, etc., Node.js provides inbuilt module called FS (File System).
Node.js Request module
Requests from different clients to the Node.js server can be handled using this request module. The request module contains routines to handle get requests, post requests, etc.
Node.js MySQL module
In most often cases, Node.js Server may require connection to a DB to store data received from clients or retrieve the data from database and serve the clients. And MySQL is popular among RDBMS. Following Node.js Tutorials help to get connected to MySQL database and do CRUD operations.
MongoDB is popular among NoSQL databases and it supports high volumes of data. If you planning to build a service or some sort of that, where you can expect high throughput of data, following tutorials help you in integrating MongoDB with your Node.js application.
Concluding this Node.js Tutorial, we got introduced to Node.js, its capabilities, and different modules that are popular with Node.js. Follow these series of Node.js Tutorials to get hands on working with Node.js basic and advanced concepts.