Web Server

Web server is a server, it handles HTTP protocol. When web server receive the http request (Ex http://gmail.com), it respond with an http response, such as sending back an HTML page.

Example:Below are the web servers available in market


Uses of Web server:
1. Reduce the traffic to App server (all static data can handled by Web server only business logic should go Application server)
2. Most secure because it captures the end user system information like
    a. IP address,
    b. Browser information (which browser),
    c. what request user sent
   d. which OS end user using and
   e. Date and Time

Where web server residing in any Application architecture?
Web server always residing before the Application server. The request flow from client to server shown below

        Client-->Web server --->Application server ---->Data base Server.
1.Client sends the request to the server
2.web server takes the request from the client,if the request has business logic then using load balancing request will goes to the Application server
3.Request will goes to DB server using the connection pool configuration.


How Web browser Parse the HTTP request:
When given this URL, your browser performs the steps shown in below figure. In Steps 1-3, the IP address and port number of the server are pulled from the URL. A TCP connection is made to the web server in Step 4, and a request message is sent across the connection in Step 5. The response is read in Step 6, and the connection is closed in Step 7.


Here are the steps:
(a) The browser extracts the server's hostname from the URL.
(b) The browser converts the server's hostname into the server's IP address.
(c) The browser extracts the port number (if any) from the URL.
(d) The browser establishes a TCP connection with the web server.
(e) The browser sends an HTTP request message to the server.
(f) The server sends an HTTP response back to the browser.
(g) The connection is closed, and the browser displays the document.
Below is the Example:


Note: By default all website run on 80 port. Ex www.gmail.com is equal to www.gmail.com:80

In which layer HTTP request works and How it uses the OSI layers:

In this way, HTTP is the top layer in a "protocol stack" of "HTTP over TCP over IP," as depicted in Figure shown below. A secure variant, HTTPS, inserts a cryptographic encryption layer (called TLS or SSL) between HTTP and TCP .
HTTP Request Vs ISO layers
When HTTP wants to transmit a message, it streams the contents of the message data, in order, through an open TCP connection. TCP takes the stream of data, chops up the data stream into chunks called segments, and transports the segments across the Internet inside envelopes called IP packets . This is all handled by the TCP/IP software; the HTTP programmer sees none of it.


How Web Server works handles HTTP Request.

When client sends the request to the web server , below activities undergoes between client and the server