📜  Web服务器

📅  最后修改于: 2020-12-14 06:08:12             🧑  作者: Mango


总览

Web服务器是用于存储Web内容的计算机。基本上,Web服务器用于托管网站,但也存在其他Web服务器,例如游戏,存储,FTP,电子邮件等。

网站是网页的集合,而网站服务器是一种响应网站资源请求的软件。

Web服务器工作

Web服务器通过以下两种方式之一响应客户端请求:

  • 将文件发送到与请求的URL关联的客户端。

  • 通过调用脚本并与数据库通信来生成响应

internet_technologies_tutorial

关键点

  • 当客户端发送对网页的请求时,如果找到请求的页面,则网络服务器将搜索所请求的页面,然后它将通过HTTP响应将其发送给客户端。

  • 如果未找到请求的网页,则网络服务器将发送HTTP响应:错误404未找到。

  • 如果客户端请求其他资源,则Web服务器将与应用程序服务器和数据存储区联系以构造HTTP响应。

建筑

Web服务器体系结构遵循以下两种方法:

  1. 并发方法

  2. 单进程事件驱动方法。

并发方法

并发方法允许Web服务器同时处理多个客户端请求。可以通过以下方法实现:

  • 多进程

  • 多线程

  • 混合方法。

多处理

在这种情况下,单个进程(父进程)将启动多个单线程子进程,并将传入的请求分配给这些子进程。每个子进程负责处理单个请求。

父进程负责监视负载并决定是否应终止或分叉进程。

多线程

与多进程不同,它创建多个单线程进程。

杂种

它是以上两种方法的结合。在这种方法中,将创建多个进程,并且每个进程都会启动多个线程。每个线程处理一个连接。在单个进程中使用多个线程可以减少系统资源的负担。

例子

下表描述了当今最领先的Web服务器:

S.N. Web Server Descriptino
1 Apache HTTP Server
This is the most popular web server in the world developed by the Apache Software Foundation. Apache web server is an open source software and can be installed on almost all operating systems including Linux, UNIX, Windows, FreeBSD, Mac OS X and more. About 60% of the web server machines run the Apache Web Server.
2. Internet Information Services (IIS)
The Internet Information Server (IIS) is a high performance Web Server from Microsoft. This web server runs on Windows NT/2000 and 2003 platforms (and may be on upcoming new Windows version also). IIS comes bundled with Windows NT/2000 and 2003; Because IIS is tightly integrated with the operating system so it is relatively easy to administer it.
3. Lighttpd
The lighttpd, pronounced lighty is also a free web server that is distributed with the FreeBSD operating system. This open source web server is fast, secure and consumes much less CPU power. Lighttpd can also run on Windows, Mac OS X, Linux and Solaris operating systems.
4. Sun Java System Web Server
This web server from Sun Microsystems is suited for medium and large web sites. Though the server is free it is not open source. It however, runs on Windows, Linux and UNIX platforms. The Sun Java System web server supports various languages, scripts and technologies required for Web 2.0 such as JSP, Java Servlets, PHP, Perl, Python, and Ruby on Rails, ASP and Coldfusion etc.
5. Jigsaw Server
Jigsaw (W3C’s Server) comes from the World Wide Web Consortium. It is open source and free and can run on various platforms like Linux, UNIX, Windows, and Mac OS X Free BSD etc. Jigsaw has been written in Java and can run CGI scripts and PHP programs.