Thursday, 26 July 2018

Node.js Web Server Module

Node.js Web Server Module

What is Web Server?

Web Server is a software program that handles HTTP requests sent by HTTP clients like web browsers and returns web pages in response to the clients. Web servers usually respond with HTML documents along with images, style sheets, and scripts.
Most of the web server support server-side scripts using a scripting language or redirect to the application server which performs the specific task of getting data from the database, perform complex logic etc. and then sends a result to the HTTP client through the Web server. Apache web server is one of the most commonly used Web Server. It is an open source project.



Web Application Architecture

A web application can be divided into 4 layers:

Client Layer: The Client layer contains web browsers, mobile browsers or applications which can make an HTTP request to the web server.

Server Layer: The Server layer contains a Web server which can intercept the request made by clients and pass them the response.

Business Layer: The business layer contains application server which is utilized by the web server to do required processing. This layer interacts with the data layer via database or some external programs.

Data Layer: The Data layer contains databases or any source of data.
https://www.miglioretop.com and https://avisdeproduits.com


Features of Node.Js

Features of Node.js

Following are some of the important features that make Node.js the first choice of software architects.
·        Asynchronous and Event Driven − All APIs of Node.js library are asynchronous, that is, non-blocking. It essentially means a Node.js based server never waits for an API to return data. The server moves to the next API after calling it and a notification mechanism of Events of Node.js helps the server to get a response from the previous API call.
·        Very Fast − Being built on Google Chrome's V8 JavaScript Engine, Node.js library is very fast in code execution.

·        Single Threaded but Highly Scalable − Node.js uses a single threaded model with event looping. Event mechanism helps the server to respond in a non-blocking way and makes the server highly scalable as opposed to traditional servers which create limited threads to handle requests. Node.js uses a single threaded program and the same program can provide service to a much larger number of requests than traditional servers like Apache HTTP Server.
·        No Buffering − Node.js applications never buffer any data. These applications simply output the data in chunks.

·        License − Node.js is released under the MIT License

Where Should be Used Node. Js

Where Should Be Used Node.js 

CHAT

The chat application is really the sweet-spot example for Node.js: it’s a lightweight, high traffic, data-intensive (but low processing/computation) application that runs across distributed devices. It’s also a great use-case for learning too, as it’s simple, yet it covers most of the paradigms you’ll ever use in a typical Node.js application.
Let’s try to depict how it works.


In the simplest scenario, we have a single chat room on our website where people come and can exchange messages in one-to-many (actually all) fashion. For instance, say we have three people on the website all connected to our message board.

On the server-side, we have a simple Express.Js application which implements two things:

1) a GET ‘/’ request handler which serves the webpage containing both a message board and a ‘Send’ button to initialize new message input.

2) A web sockets server that listens for new messages emitted by web socket clients.

On the client-side, we have an HTML page with a couple of handlers set up, one for the ‘Send’ button click event, which picks up the input message and sends it down the web socket, and another that listens for new incoming messages on the web sockets client.

Benefits of Node JS

1. The Fast Suite

Companies are in awe of the speed at which Node.js functions. It runs on the V8 engine developed by Google that uses JavaScript into native machine code and operates at a super speed.

2. Go with Data Streaming

Generally, in web platforms, HTTP request and response are considered two separate events but actually, they are data streams. This feature can be utilized to its fullest with Node.js to create some of the best attributes.

3. Present Everywhere

JavaScript is present now in the browser as well as the server just because of Node.js. Be it the browser or server, Node.js code runs in a similar manner and is flexible in usage.

4. Real-Time Web Applications

Worried about low-level sockets and protocols? Let that be a thing of the past as Node.js is here to build real-time web applications at a lighting speed just at the same time required to make a simple blog in PHP.




5. Solves All Database Queries

The database queries for new NoSQL databases like MongoDB, CouchDB have the JavaScript framework. Developers need not modulate the syntax differences while uniting the Node.js and NoSQL databases.

6. Easy On Coding

Node.js allows developers to write JavaScript for both the server and the client thus making it convenient to transport data between the server and the client to coordinate the working simultaneously.

7. Dynamic NPM

As Node.js is an open-source technology, it gives an edge with a shared repository of dynamic tools and modules. The amount of modules that are more than 60000 in the Node Package Manager (NPM) has risen with a significant growth and is on the point of beating the RoR (Ruby on Rails) platform.

8. In Charge With Proxy Server

Node.js comes to rescue to proxy different services that have different response times or for collecting data from diverse sources.


Node.js Web Server Module

Node.js Web Server Module What is Web Server ? Web Server is a software program that handles HTTP requests sent by HTTP clients li...