Tareq
5 min readDec 19, 2020

--

Server and Node.js

ACC Assignment-1

  • What is a web server?

A web server is software and hardware that uses HTTP(Hypertext Transfer Protocol) and other protocols to respond to client requests made over the World Wide Web. The main job of a web server is to display website content through storing, processing and delivering web pages to users. Besides HTTP, web servers also support SMTP (Simple Mail Transfer Protocol) and FTP (File Transfer Protocol), used for email, file transfer and storage.

Web server hardware is connected to the internet and allows data to be exchanged with other connected devices, while web server software controls how a user accesses hosted files. The web server process is an example of the client/server model. All computers that host websites must have web server software.

Web servers are used in web hosting or the hosting of data for websites and web-based applications or web applications.

  • Different types of web server?

The five leading web servers in the market are:

1. Apache HTTP Server

2. Microsoft Internet Information Services

3. Lighttpd

4. Nginx Web Server

5. Sun Java System Web Server

  1. Apache HTTP Server

Apache HTTP server is one of the most widely used web servers worldwide. The biggest advantage of using this server is that it supports almost all operating systems such as Windows, Linux, Apple Mac OS, Unix, and others. Around 60% of the web server machines worldwide, run the Apache Web Server.Apache HTTP Server is open-source. Being open-source means it is available for free, and can easily be accessed through online communities. Thus, a lot of online support is available in case of a problem or an error. This also enables the user to modify the server as per his requirements. Apache’s latest version is much more flexible than the previous ones and can handle more requests smoothly.

2. Microsoft Internet Information Service

IIS is a Microsoft product that offers almost all the features that Apache HTTP server provides. Microsoft IIS is not open source. This means that it has some development limitations, and the users cannot modify it as per their project requirements. The project has to be modified around it. It works with every Windows OS gadget. Microsoft provides ‘customer care and helps’ to its users in case of any issue.

3. Lighttpd (pronounced ‘Lightly’)

Lighttpd is a combination of ‘light’ and ‘httpd’ and was released in 2003. It is not as popular as Apache and IIS, however, its small CPU load and speed optimizations stand it apart from its competitors. It can run a large number of connections at the same time and even provides facilities like Auth, URL rewriting, flexible virtual hosting, servlet support (AJP), HTTP proxy support, etc to the user. All these features along with being lightweight make Lighttpd suitable for servers suffering from load problems.

4. Nginx Web Server (pronounced ‘engine-x’)

Just like Lighttpd, it is also an open-source web server, well known for the performance that it provides at low resource and configuration. It is mainly used for caching, media streaming, load balancing, handling of static files, auto-indexing, etc. Instead of creating new processes for each request made by the user, Nginx handles the requests in a single thread, using an asynchronous approach.Nginx has started to get some recognition in the market nowadays, and about 7.5% of the domains worldwide use it.

5. Sun Java System Web Server — SJSAS

It is a multi-threaded and multi-process web server that provides high performance, scalability, and reliability to the enterprises. It also provides data security and command-line interface CLI support. The newest version of this webserver (7.0) uses a newly introduced CLI called ‘wadm’.The 7.0 version web server does not support HttpServerAdmin. However, it comes with a built-in migration tool that helps in migrating apps, websites, and it’s configurations from the older to a newer version of SJSAS hasslefree.

  • Differences between GET ,POST, put, PATCH, DELETE

GET, POST, PUT, PATCH, and DELETE are the five most common HTTP methods for retrieving from and sending data to a server.

The GET method

The GET method is used to retrieve data from the server. This is a read-only method, so it has no risk of mutating or corrupting the data. For example, if we call the get method on our API, we’ll get back a list of all to-dos.

The POST method

The POST method sends data to the server and creates a new resource. The resource it creates is subordinate to some other parent resource. When a new resource is POSTed to the parent, the API service will automatically associate the new resource by assigning it an ID (new resource URI). In short, this method is used to create a new data entry.

The PUT method

The PUT method is most often used to update an existing resource. If you want to update a specific resource (which comes with a specific URI), you can call the PUT method to that resource URI with the request body containing the complete new version of the resource you are trying to update.

The PATCH method

The PATCH method is very similar to the PUT method because it also modifies an existing resource. The difference is that for the PUT method, the request body contains the complete new version, whereas for the PATCH method, the request body only needs to contain the specific changes to the resource, specifically a set of instructions describing how that resource should be changed, and the API service will create a new version according to that instruction.

The DELETE method

The DELETE method is used to delete a resource specified by its URI.

Assignment-2

  • What is node.js?

Node.js is a JavaScript runtime built on Chrome’s V8 JavaScript engine. & As an asynchronous event-driven.

  • How does node.js work?

Node JS is a JavaScript runtime environment. Both browser and Node JS run on V8 JavaScript engine. Node JS uses an event-driven, non-blocking I/O model that makes it lightweight and efficient. Node JS applications use single threaded event loop architecture to handle concurrent clients. Actually its main event loop is single threaded but most of the I/O works on separate threads, because the I/O APIs in Node JS are asynchronous/non-blocking by design, in order to accommodate the main event loop. Consider a scenario where we request a backend database for the details of user1 and user2 and then print them on the screen/console. The response to this request takes time, but both of the user data requests can be carried out independently and at the same time. When 100 people connect at once, rather than having different threads, Node will loop over those connections and fire off any events your code should know about. If a connection is new it will tell you .If a connection has sent you data, it will tell you .If the connection isn’t doing anything ,it will skip over it rather than taking up precision CPU time on it. Everything in Node is based on responding to these events. So we can see the result, the CPU stays focused on that one process and doesn’t have a bunch of threads for attention.There is no buffering in Node.JS application it simply outputs the data in chunks.

--

--