A web server is a computer where the web content is stored. Basically, the webserver is used to host the websites but there exist other web servers also such as gaming, storage, FTP, email, etc.
Web site is collection of web pages whileweb server is a software that respond to the request for web resources.
Web Server Working
Web server respond to the client request in either of the following two ways:
- Sending the file to the client associated with the requested URL.
- Generating response by invoking a script and communicating with database
- When client sends request for a web page, the web server search for the requested page if requested page is found then it will send it to client with an HTTP response.
- If the requested web page is not found, web server will the send an HTTP response:Error 404 Not found.
- If client has requested for some other resources then the web server will contact to the application server and data store to construct the HTTP response.
Web Server Architecture follows the following two approaches:
- Concurrent Approach
- Single-Process-Event-Driven Approach.
Concurrent approach allows the web server to handle multiple client requests at the same time.
It can be achieved by following methods:
- Hybrid method.
In this a single process (parent process) initiates several single-threaded child processes and distribute incoming requests to these child processes.
Each of the child processes are responsible for handling single request.
It is the responsibility of parent process to monitor the load and decide if processes should be killed or forked.
Unlike Multi-process, it creates multiple single-threaded process.
It is combination of above two approaches. In this approach multiple process are created and each process initiates multiple threads. Each of the threads handles one connection.
Using multiple threads in single process results in less load on system resources.