In the opinion of many users, the success or failure of a Web website mainly lies in the content and functions provided by it. But the Web server that supports these content and functions is the real hero behind the scenes. According to statistics, there are more than 5 million websites around the world. A Web server is running behind each website. What is a Web server? How does it work ?...... The earliest network system from C/S to Web is a simple host/terminal system. All applications are completed by the host, and the terminal only runs the corresponding programs on the server. The arrival of the PC era has greatly improved computer networks and applications, there are fewer and fewer applications for terminal-oriented large hosts. In particular, the rise of network operating systems such as NetWare and Windows NT and the emergence of network database systems have opened up a new network application model-C/S (Client/Server-Client/Server) mode. The C/S mode is a two-layer system. The first layer is to process the logic and business logic on the client, and the second layer is the server systems such as databases running through the network. In the C/S mode, transactions are processed separately to achieve distributed computing of the network. Over a long period of time, it has also helped enterprises implement LAN construction, improved internal business management, and improved work efficiency. However, the C/S mode has obvious limitations in system integration and maintenance, operating interface consistency, and system scalability, therefore, just as the host/terminal network is replaced by a network system in the C/S mode, an updated system mode will also appear in the Internet/Intranet technology environment. Internet/Intranet Based on Web technology has been widely used in recent years. Intranet is an enterprise Intranet based on TCP/IP protocol and with Web as the core, with a low-cost, easy-to-use client browser, you can access your desired data on the enterprise's Web site anytime and anywhere. The consistency of the browser client operation interface avoids the diversity of client programs in the C/S mode. The open and standard connection solutions on the server allow enterprises to easily contact the outside world through the Internet. At the same time, the dynamic and interactive publishing of Web Information has fundamentally changed the service quality of enterprises and increased their business opportunities. Figure 1 Web layer-3 structure in the layer-3 Web technology, the database does not directly provide services to each client, but communicates with the Web server, it achieves dynamic, real-time, and interactive information services for customers. This function is implemented through Server Applications created by CGI, ISAPI, NSAPI, and Java. 1. What is Web Server? What is unique in Web technology is Hyperlink and multimedia information. Web servers use HTML-HyperText Marked Language to describe network resources and create Web pages for Web browsers to read. HTML documents are characterized by interactivity. Both common text and graphics can be connected to other documents on the server through links in the document, so that customers can quickly search for the information they want. HTML web pages also provide forms for users to fill in and submit to the database through the server application. This type of database generally supports multimedia data. Web Browser is a client application for document retrieval and display. It is connected to the Web server through HyperText Transfer Protocol (HTTP. The general and low-cost browser reduces the development and maintenance costs of the two-layer C/S Mode client software. Currently, popular Internet Explorer and Netscape Navigator not only provide basic document retrieval, display, and navigation features, but also support advanced HTML display (such as tables and frames) and ActiveX, Java, JavaScript and other features. In the view of many users, the success or failure of a Web server lies in the content and functions provided by it, but the Web servers that support these content and functions are the real heroes behind the scenes. How does a Web server work? A few years ago, when the Web server just appeared, it only supported the browsing of simple HTML files and images, when the Web server received a request for a Web page, such as a http://www.ccidnet.com.index.html, the URL (Uniform Resource locator-unified Resource Locator) is used to locate the corresponding client file server and find the corresponding file index.html. Then, the file is downloaded from the host file server and transmitted to the Web Browser through the HTTP protocol ). Of course, this is just a basic function. The relationship between Web servers and Web browsers is far from that simple. One of the most important extensions of Web applications is the introduction of dynamic content. For example, a Web server can directly or indirectly create a Web page based on user input requests, and then return it to a Web browser. The earliest way to implement dynamic content application is through CGI (Comman Gateway Interface public Gateway Interface ), it has a basic definition of program running on the Web server and transmission of dynamic content between the Web server and the Web browser. 2. Another development of Web applications is the emergence of HTTPS (HyperText Transmission Protocol, Secure HyperText Transfer Protocol), which ensures the communication security between Web servers and Web browsers, this makes electronic transactions possible. Communication between Web servers and Web browsers is performed through the HTTP protocol. What is the HTTP protocol? Simply put, HTTP is an application layer protocol between a Web browser and a Web server. It is based on the TCP/IP protocol and is a common, stateless, and object-oriented protocol. Its working principle consists of four steps: Figure 2 CGI definition graph connection: the Web browser establishes a connection with the Web server to open a virtual file called socket, the establishment of this file indicates that the connection is successful. Request: the Web browser submits a request to the Web server through socket. Response: After a Web browser submits a request, the request is sent to the Web server over HTTP. After the Web server receives the request, it processes the transaction and returns the result to the Web browser over HTTP, so that the requested page is displayed on the Web browser. Close connection: After the response is over, the Web browser and the Web server must be disconnected to ensure that other Web browsers can establish a connection with the Web server. In this way, the processing process of the Web Server includes a complete logical phase: accept connections-generate static or dynamic content and send them back to the browser-close the connection-Accept the next connection, so proceed. As you can imagine, when there are many visitors, the server will inevitably be overwhelmed. Two technologies can be used to solve this problem: multithreading and multi-process. The Web server supports port monitoring modules of Unix systems (a multi-process mode), multithreading, multi-process, or a mixture of two technologies. With the connection, how does the Web server provide content to the Web browser? The key here is that the content must be recognized and displayed by the browser. The primary mechanism for determining how to display content is the MIME (Multiple Purpose Internet Mail Extension-multi-Purpose Internet Mail Extension) type. MIME will tell the Web browser what kind of documents will be sent, and, this type of identification is not limited to simple image documents and HTML documents. For example, there are 370 default MIME types in the mine. type configuration file of Apache WebServer, and this is not all of the MIME types. The MIME type is distinguished by the type/subtype syntax related to the file suffix. For example, a file containing the MPEG video content has a suffix of mpeg, mpg, or mpe. The role of Web servers is ultimately reflected in the provision of content, especially dynamic content, which is also the fundamental difference between Web servers and application servers, the Web server is mainly responsible for providing dynamically generated HTML documents when interacting with Web browsers (in addition to providing HTML document services, the Web server also provides application data such as XML format, that is, the Web server not only provides HTML documents, but also can establish connections with various data sources in a larger scope to provide richer content for Web browsers .) There are many technologies for implementing dynamic Web content. The first is CGI, which dynamically transmits HTML data based on user input requests. CGI is not a development language. It is only a protocol that can implement Web servers using programs written for it. Since each request for dynamic content needs to start a new CGI program, it will increase the burden on the Web server, therefore, a major defect of CGI is that it easily affects the speed of Web servers. Microsoft ASP (Active Server Pages-Dynamic Server Pages) technology is composed of VBScript interpreters embedded in IIS. It also supports multiple scripting languages, including JavaScript, PerlScript, and VBScript, based on COM, it can easily access software components of other servers. Like JSP and ASP, PHP is composed of a set of additional code tags placed in HTML documents. The difference is that it is used for developing Web pages. Therefore, applications developed using it are more concise than those developed using VBScript or JSP. Today, all Web servers support the Perl Acceleration Solution. Apache's mod_perl free solution embeds Perl into the Apache server. This not only improves the speed of interpretation of Perl code, but also greatly improves the code execution efficiency due to mod_perl caching. Mod_perl is also closely connected with Apache, so Perl developers can control the work of Web servers just like C developers compile underlying Apache API programs. When the system is running, Web servers often need to support a large number of intensive user clicks and dynamic content requirements. Therefore, even if the high-end server equipment is used to face the increasing number of users, the access volume supported per unit time is also limited, especially when there are many dynamic content, because the application of dynamic content needs to frequently call the database data and applications, it will occupy a large amount of server resources. In this case, the server load needs to be distributed between multiple server devices or between multiple sites. There are many load balancing methods. The simplest method is to allocate website content between different servers. For example, you can store static HTML pages on one server and image files on the other, and run all CGI programs on the third server. However, it is obvious that this method is not very efficient because it cannot implement automatic content allocation between hosts. If there is too much content in one aspect, it will still form a load bottleneck. The basic method of DNS load balancing is to place different copies of the same site on the same physical Server. Then, the DNS Server can return multiple IP addresses, the DNS server can return multiple IP addresses of the domain name or different IP addresses for the same DNS request. It is difficult to determine which IP address a client corresponds to, so DNS can only provide basic load balancing services. In addition, because DNS requests remain in the cache of the client and other servers, the same client will continue to access the same Web server. Therefore, a large number of frequently accessed users may use one IP address, while a small number of other users access another IP address, resulting in uneven distribution. Another problem is that the DNS cache is not continuously activated, which may cause access to other IP addresses of the website to end when a client is using a Web site. This will cause problems for dynamic websites, especially when the client data needs to be accepted and stored. The Software and Hardware load balancing method is similar to DNS load balancing, but the website only publishes one IP address, A machine is specially set to accept HTTP requests for this IP address and distribute these requests to each server of the website. This distribution usually occurs at the layer of TCP/IP routing, and can transparently map this single source/Target IP address to a specific server. This technology