Cognitive Web server _php Tutorial

Source: Internet
Author: User
Tags domain name server
For many users, the success or failure of a Web site is primarily the content and functionality it provides, and the Web server that supports those content and functionality is the real hero behind it. According to statistics, there are 500多万个 websites all over the world. There is a Web server running behind every Web site, so what is a Web server? How does it work?   ...... From c/S to the Web The earliest network system is a simple host/terminal system, all the applications are completed by the host, the terminal just run the corresponding program on the server. The advent of PC era, so that computer networks and computer applications have been greatly developed, due to the constant decline in the price of PC and the performance of the continuous improvement of the terminal-oriented mainframe applications more and more less. In particular, the emergence of network operating systems such as NetWare and Windows NT, as well as the advent of network database systems, has opened up a new mode of network application--C/S (client/server-client/server) mode. The C/S mode is a two-layer structure system, the first layer is to handle the representation logic and business logic on the client, the second layer is the server system which runs through the network database. The C/S mode handles the transaction separately, realizes the distributed computing of the network, and helps the enterprise to realize the local area network construction for a long time, consummates the enterprise internal business management, and improves the work efficiency.   However, the C/S model has obvious limitations in the integration and maintenance of the system, the consistency of the Operation interface and the expansibility of the system, so it is like the host/terminal network is replaced by the network system of C/S mode, in the Internet/intranet technology environment, there will be an updated system mode. Web-based internet/intranet has been widely used in recent years, the intranet is based on the TCP/IP protocol, web-centric enterprise intranet, the user through low-cost, The easy-to-use customer browser will be able to access the data you need on your corporate web site, anytime, anywhere. The consistency of the browser client interface avoids the diversity of client programs in C/S mode, while the server-side open and standard-based connection scheme makes it easy for enterprises to connect with the outside world through the Internet, and the dynamic and interactive publishing method of Web information fundamentally changes the service quality of the enterprise.   Increased business opportunities for businesses. Figure 1 The Web three-tier structure in the three-tier Web technology, the database is not directly to each client to provide services, but to communicate with the Web server, to achieve the customer information service dynamic, real-time and interactive. This functionality is implemented through server applications such as CGI, ISAPI, NSAPI, and Java.   As shown in 1. What is unique about Web server Web technology is the use of hyperlinks and multimedia information. WThe EB server uses Hypertext Markup Language (Html-hypertext Marked Language) to describe the resources of the network and create Web pages for the Web browser to read. HTML documents are characterized by interactivity. Both general text and graphics can be connected to other documents on the server through links in the document, allowing customers to quickly search for the information they want. HTML pages can also provide forms for users to fill out and submit to the database through a server application.   This kind of database is generally supported by multimedia data types. A Web browser (Web Browser) is a client application for document retrieval and display and is connected to a Web server via Hypertext Transfer Protocol HTTP (Hypertext Transfer Protocol). A common, low-cost browser saves the cost of developing and maintaining a two-tier client software for C/s mode.   At present, the popular Internet Explorer and Netscape Navigator, in addition to providing basic document retrieval, display and navigation features, also support advanced HTML display (such as tables and frames) as well as ActiveX, Java, JavaScript and other features. How a Web server works in the eyes of many users, the success or failure of a Web site is primarily the content and functionality it provides, and the Web server that supports these content and functionality is the real hero behind the scenes.   So, how does a Web server work? A few years ago, when the Web server just appeared, it supported applications that were simply HTML files and images, when the Web server received a request for a Web page, such as HTTP.// www.ccidnet.com.index.html, the URL (Uniform Resource locator-Uniform Resource Locator) is targeted to the appropriate host file server. and locate the appropriate file index.html, then download the file from the host File server and transfer it to the Web browser (web Browser) over the HTTP protocol. Of course, this is just a basic feature, and the relationship between Web servers and Web browsers is far from simple. One of the most important extensions of Web applications is the introduction of dynamic content. For example, a Web server can create a Web page directly or indirectly, based on a request entered by a user, and then return it to a Web browser. The first way to implement a dynamic content application is through CGI (Comman Gateway Interface Public Gateway Interface), which has a basic definition of the operation of the program on the Web server and the transmission of the dynamic content between the Web server and the Web browser.   As shown in 2. Another development for Web applications is HTTPS (HypertexT transmission Protocol, Secure Hypertext Transfer Protocol, which ensures the security of communications between Web servers and Web browsers, thus making electronic transactions possible. The communication between the Web server and the Web browser is through the HTTP protocol, so what is the HTTP protocol? Simply put, the HTTP protocol is the application layer protocol between Web browser and Web server, which is based on TCP/IP protocol and is a universal, stateless, object-oriented protocol.   It works in four steps: Figure 2 CGI definition diagram connection: Web browser establishes a connection to a Web server, opens a virtual file called a socket (socket), and the creation of this file marks a successful connection.   Request: The Web browser submits a request to the Web server through a socket. Answer: After the Web browser submits the request, it is routed to the Web server via the HTTP protocol.   After the Web server is received, the transaction is processed, and the results are passed back to the Web browser via HTTP to display the requested page on the Web browser.   Close connection: When the answer is finished, the Web browser and Web server must be disconnected to ensure that other Web browsers can connect to the Web server. In this way, the processing of the Web server involves a complete logical phase: accepting connections-producing static or dynamic content and passing them back to the browser-closing the connection-accepting the next connection, and so on. As you can imagine, the server must be overwhelmed by the number of visitors. There are two techniques for solving this problem: multithreading and multi-process.   The Web server supports the UNIX system's Port monitoring module (a multi-process mode), multi-threaded, multi-process, or hybrid of both technologies. With connections, how does a Web server provide content to a Web browser? The key here is that the content must be recognized and displayed by the browser. The main mechanism for determining how content is displayed is the MIME (multiple Purpose Internet Mail extension-Multipurpose Internet Mail Extension) type, which mime tells the Web browser what kind of document 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 for Apache WebServer, and this is not all of the MIME type.   MIME types are distinguished by the type/subtype syntax associated with the file suffix, for example, files that contain MPEG video content have a suffix of mpeg, MPG, or MPE. The role of Web servers is ultimately the provision of content, especially dynamic content, which is also the Web server and application serverFundamentally different, Web servers are primarily responsible for providing dynamically generated HTML documents when interacting with Web browsers (in addition to providing HTML document services, Web servers also provide application data such as XML, which means that Web servers not only provide HTML documents, You can also connect to a variety of data sources in a larger scope and provide richer content for your Web browser. There are many techniques for implementing web dynamic content, the first of which is CGI, which dynamically transmits HTML data based on user input requests. CGI is not a development language, it is just a protocol that can be used to implement a Web server with programs written for it.   Because every request for dynamic content needs to start a new CGI program, which increases the burden on the Web server, a big flaw in CGI is the ease of affecting the speed of the Web server. The Microsoft ASP (Active Server pages-Dynamic Servers page) technology consists of a VBScript interpreter embedded in IIS, and it supports a variety of scripting languages, including JavaScript, PerlScript, and VBScript   , based on COM, it makes it easy to access the software components of other servers. PHP, like JSP and ASP technology, consists of a set of additional code tags placed in an HTML document.   The difference is that it is designed for Web pages, so applications developed with it will be more concise than the corresponding applications developed with VBScript or JSP. All Web servers today Support Perl's 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 execution efficiency of the code due to the Mod_perl caching effect.   Mod_perl is also closely linked to Apache, so Perl developers can control the work of the Web server just as the C language developer writes the underlying Apache API program. When the system is running, the Web server is often to support a large number of user clicks and the demand for dynamic content, so even if the high-end server equipment, in the face of the increasing number of users, the amount of traffic supported per unit of time will have a limit, especially for the dynamic content of the situation, Because the application of dynamic content requires frequent calls to the database's data and applications, it consumes a lot of server resources.   At this point, you need to distribute the server load between multiple server devices or between multiple sites. There are many ways to load balance, and the simplest way is to distribute the content of the site between different servers. For example, a static HTML page is stored on one server, another contains an image file, and all CGI programs are run on the third stage. However, it is clear thatThis approach is not very efficient because it does not enable automatic content allocation between hosts, and if there is too much content in one of them, it can still form a load bottleneck. The basic method of DNS load balancing (domain name server-name server) is to place different copies of the same site on the same physical server, and then the DNS server can return multiple IP addresses by returning multiple IP addresses for the domain name by the DNS server. You can also return different IP addresses for the same DNS request. Because it is difficult to determine which IP address a client corresponds to, DNS can only provide basic load-balancing services. Also, because DNS requests remain in the cache of clients and other servers, the same client continues to access the same Web server. Therefore, it is possible to cause a large number of frequent users of the Internet with an IP address, while less users of the Internet access to another IP address, resulting in uneven distribution. Another problem is that the DNS cache is not continuously activated, which can result in the end of access to other IP addresses of the site when a client is using a Web site.   This poses a problem for dynamic Web sites, especially if you need to accept and store the client's data. The load balancing method of hardware and software is similar to DNS load balancing, but the Web site only publishes an IP address, specifically setting up a machine to accept HTTP requests for this IP address and distributing these requests to the individual servers of the Web site. This distribution typically occurs at the level of TCP/IP routing, and can transparently map this single source/destination IP address to a specific server. This technology

http://www.bkjia.com/PHPjc/532255.html www.bkjia.com true http://www.bkjia.com/PHPjc/532255.html techarticle For Many users, the success or failure of a Web site is primarily the content and functionality it provides, and the Web server that supports those content and functionality is the real hero behind it. According to statistics ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.