Web server, Application server, Web container, reverse proxy server difference and contact

Source: Internet
Author: User


Brother Shuai

Source: www.cnblogs.com/vipyoumay/p/7455431.html(click the tail to read the original)

We know that people of different colors have a big difference in appearance, and twins are difficult to identify. The interesting thing is that the Web server/web container/web Application Server/reverse proxy is a bit like a four-cell fetus, often appearing together on the network. This article will take readers to how to distinguish the four similar concepts.

1. Understanding Web server, Application server, Web container, reverse proxy server difference and contact

      • 1.1. Web Server Concepts and fundamentals

        • 1.1.1. History of the Web server

        • 1.1.2. How Web servers work

      • 1.2. Web application container Concepts and fundamentals

        • 1.2.1. The origin of the Web application container

        • 1.2.2. How the Web application container works

      • 1.3. Web application Server Concepts and fundamentals

      • 1.4. Reverse Proxy concepts and fundamentals

        • 1.4.1. Basic concept of Reverse proxy

        • 1.4.2. Basic working principle of reverse Proxy

    • 1.5. Summary

  1.1. Web server Concepts and Fundamentals

1.1.1. History of the Web server

In 1989, the father of the Internet, Berners-lee, proposed a new project to his employer, CERN, to ease the exchange of information between scientists by using hypertext systems. The project resulted in the development of two programmes in Berners-lee in 1990 years:

    • A browser named WorldWideWeb.

    • The world's first Web server, later known as CERN httpd, runs on NeXTSTEP
      During the period from 1991 to 1994, the simplicity and effectiveness of the early technologies used to surf and exchange data through the World Wide Web helped to migrate them to many different operating systems and to scientific organizations and universities, and then to the industry.

In 1994, Berners-lee decided to form the World Wide Web Consortium to manage the further development of many of the technologies involved (http,html, etc.) through a standardized process.

This is the server:

The main function of a Web server is to store, process, and deliver Web pages to customers. Communication between the client and the server is done using Hypertext Transfer Protocol (HTTP). The most common type of page delivered is an HTML document that, in addition to the text content, may contain images, stylesheets, and scripts.

A user agent, usually a Web browser or web crawler, that, by initiating an HTTP request to obtain server resources, the server returns the resource on request or responds to an error message for some reason. This resource is typically a real file on server secondary storage, but this is not necessarily the case, depending on how the Web server is implemented.

Although the main function is to provide content, the full implementation of HTTP also includes how the content is received from the client. This feature is used to submit Web forms, including uploading files. Many common Web servers also support server-side scripting using Active Server Pages (ASP), PHP, or other scripting languages. This means that the behavior of the Web server can be scripted in a separate file, while the actual server software remains intact. Typically, this function is used to dynamically generate HTML documents ("instant") instead of returning static documents. The former is mainly used to retrieve or modify information from the database. The latter is usually much faster and more easily cached, but does not provide dynamic content.

Web servers are not only used for world Wide Web services. They can also be embedded in devices such as printers, routers, network cameras, and only serve local networks. The Web server can then be used as part of a system for monitoring or managing the discussed devices. This usually means that no additional software needs to be installed on the client computer because only one web browser is required (most operating systems are now included).

1.1.2. How Web servers work

The HTTP protocol is based on the TCP protocol and is an application-layer protocol for user agents and Web servers to communicate. Web servers usually work in a single-answer way:

1. The user initiates a resource request on the user agent, including but not limited to: Specifies the unique identifier of the resource IRI, indicating the type of action (Get/post/delete/put ... )

2. The user agent resolves the user input IRI and obtains the target domain name from the DNS server. If an IP address is specified in IRI, this does not need to be this step.

3, if the session with the server has not been established, at this time to establish a TCP connection, and complete the HTTP negotiation (to determine the mutually acceptable processing methods, including protocol version, whether encryption, content format, etc.).

4. The user agent encapsulates the request content into an HTTP packet and sends it to the server.

5. The server receives the resource request and unpack and process it in a way previously negotiated.

6. The resource requested by the server is encapsulated into an HTTP packet and returned to the user agent.

Next, let's talk about how the server side works.

    • TCP Listening Module

The server listens on a port (typically the default is port 8080, the user can set up additional ports) to establish a connection to the user agent. Once the connection is established, subsequent HTTP requests from the user agent are no longer required to enter the listening module.

    • Pretreatment

Here are the main three things: 1. Gets the HTTP request message from the TCP message. 2. According to the consultation with the user agent decryption, decompression, security processing and so on. 3. According to the server's own configuration for security processing, establish session state and so on.

    • ur routing

Resolves URL strings and actions to determine the resources of a user agent request, routed to a static resource processing module or a dynamic resource processing module based on a matching rule (usually based on a regular expression + suffix).

    • Static resource Processing module

Responsible for locating static resources, such as HTML/JAVASCRIPT/CSS files/images/images, determining whether the content is a stream of characters or a stream of bytes, and determining the corresponding MIME, such as HTML generating a stream of characters mime to text/html, MPEG video file generated MIME as video The/mpeg byte stream.

    • Dynamic Resource Processing Module

Run business logic processing, dynamically determine the content and type of resources returned, content and type of processing principles above.

    • Post-processing

Encryption, compression, security processing, and so on, based on protocols negotiated with the user.

    • Resource Output Module

The processed content and type are encapsulated into an HTTP message, and a TCP message is sent to the user agent on the other end of the TCP connection (the content is an HTTP message).

Mainstream Web server

including Apache, IIS, Nginx, the market share is as follows

There are more use Tomcat,jetty,websphere,weblogic,kerstrel and so on.

1.2. Web application container concepts and fundamentals

1.2.1. The origin of the Web application container

The advent of Web servers marked the emergence of the WWW era, the world has become more flat. The creators who tasted the sweetness began to be unsatisfied with the access to static resources on the Internet, and the CGI scripts were used to dynamically acquire resources. Then the direction of network development is to enhance the ability of the Web server to dynamically acquire resources forward. The following are representative dynamic technologies:

Technical Terms features  
CGI (Common Gateway Interface, Public Gateway Interface) Run in a standalone process that can be developed in multiple languages, such as c,c++,vb,perl, flexible but inefficient, and maintenance complex
Php Server-side embedded HTML script, open source, powerful, poor extensibility
Jsp Server-side embedded HTML script, cross-platform, before deployment need to compile, the main disadvantage is to write JSP more complex, need to be familiar with Java and related technology
Asp Server-side embedded HTML script, easy to develop, powerful, can only run under Windows

The Web server then moves toward an enterprise-wide application, rapidly changing business, forcing web developers to face new challenges: How to quickly write a robust, reliable, business-friendly program and deploy it smoothly? An effective way to solve this challenge is to create a WEB application development framework (including a running environment, such as an explanation of execution Jsp,web API), which solves robustness, reliability issues, and provides a fast development interface. In other words, developers only need to focus on the implementation of the business itself, and the framework can be customized and extended if there is a higher demand. Another name for this framework is the Web application container.

1.2.2. How the Web application container works

In general, the Web application container is the following constituent system:

Note: The light blue module is the main use module to implement the business program.

This container adds or strengthens the following modules relative to the Web server:

    • Assigning Thread pool Resources

The container allocates a thread for each request to process, usually taking a thread pool in a way that efficiently justifies CPU resources.

    • Encapsulate Request Context

A request corresponds to a requesting context, which mainly encapsulates the main composition of the user request: the Url,http request header, and the Session,cookie object based on the request header, for easy programming.

    • Encapsulate Response Context

A request corresponds to a response context, which is used primarily to return resources to the user agent. You can write to the output stream, or redirect it, or return an error code, and so on.

    • URL Routing

In the container, run the developer to set different routing matching rules, such as let. The HTM returns. HTML and can also be customized. XYZ returns an. HTML resource. A more flexible configuration can refer to Java MVC or the configuration scheme of ASP.

    • Dynamic Resource Processing Module

Usually here the specific container and development language have their own efficient development model, such as Java servlet,asp. NET Web Form,mvc.

    • Recycling Resources

This will reclaim the thread resources just now, and for thread reuse, unless the server is idle, the thread is typically returned to the thread pool.

As you can see, the Web container itself has the function of being a Web server, in fact the server that usually implements the Web container function is a Web server. For example, Tomcat, IIS, Jetty.

Mainstream web Container

Includes Tomcat, IIS, Jetty.

There are more use websphere,weblogic and so on.

1.3. Web application Server Concepts and Fundamentals

In the same period of Web server development, the application server has been in existence and has been developing for a long time. Some companies have developed tuxedo (transactional-oriented middleware), Topend, Encina and other products for UNIX, which derive from a host application management and monitoring environment similar to IMS and CICS. Most of these products specify a "closed" product-specific communication protocol to interconnect fat clients ("fat" client) and servers. In the 90 's, these traditional application server products began to embed HTTP communication capabilities and were just beginning to be implemented using gateways. Soon the line between them began to blur.

At the same time, the Web server is becoming more and more mature, can handle the higher load, more concurrency and better features, and the application server begins to add more and more HTTP-based communication functions. All of this leads to a narrower line between the Web server and the application server.

Currently, the line between the application server and the Web server has become blurred. But the two terms were also distinguished as an emphasis on use.

When someone says "Web server", you usually think of it as an HTTP-centric, Web-ui-guided application. When someone says "application server," You might think of "high load, enterprise features, transactions and queues, multichannel communication (HTTP and more protocols)." But it is basically the same product that provides these requirements.

Describes a typical Web application server's structure diagram:

You can see that the Web application server includes a Web container, with built-in support for enterprise application transactions, security, integration, communication, high availability and so on, greatly reducing the amount of duplication of development, ensuring the rapid development and deployment of business systems, and it is a Web server itself. Web application servers can choose to use a heavyweight product such as WebLogic and WebSphere, or use a web Containner like Tomcat, Jetty, and a third-party framework (spring,hibernate, etc.) To build your own application Server;. NET core platform, you can choose IIS, Apache,nginx and ASP.

1.4. Reverse Proxy concepts and fundamentals

1.4.1. Basic concept of Reverse proxy

A reverse proxy is one of the proxy servers. It obtains resources from back-end servers, such as Web servers, based on client requests, and then returns those resources to the client. Unlike the forward proxy, the forward proxy acts as a medium to return the resources obtained on the Internet to the associated clients, while the reverse proxy is used as a proxy on the server side (such as the Web server) instead of the client. The client can access many different resources through the forward proxy, and the reverse proxy is where many clients access resources on different back-end servers without needing to know the existence of these back-end servers, and to assume that all resources come from this reverse proxy server.

The request from the Internet is sent to the reverse proxy, and the reverse proxy forwards the request to the server in the intranet.

The main functions of the reverse proxy are:

    • Encryption and SSL acceleration

    • Load Balancing

    • Caching Static Content

    • Compression

    • Slow upload

    • Security firewall

    • External network release

    • Breaking the Internet blockade

    • Troubleshoot cross-domain issues

1.4.2. Basic working principle of reverse proxy

The composition and processing of a reverse proxy server is as follows:

Left light yellow function module external network message processing, the right gray function module for the internal network message processing

    • TCP Listening Module

Listen for TCP requests, where the request is a request that the content of the message is an application-layer protocol such as Http,ftp,email. As to whether there will be a separate thread to start processing, this is determined by the server itself, the most popular is the first into the message queue and then asynchronous processing, which can greatly improve the throughput and stability of the agent.

    • Match the proxy server

The proxy server is based on a table (the corresponding relationship between the external URL and the intranet server, usually manually set up), if the match to continue processing, or according to the extranet protocol, return error information, such as HTTP protocol this returns 404.

    • Apply a load balancing policy

If you compare large-scale Internet applications, in order to solve the single point problem for the overall system stability, it is necessary to forward the message to the proxy server according to the custom policy. A simple strategy is hash distribution or random distribution, which can typically be configured and selected by the user.

    • Pretreatment

This is based on a negotiated extranet application protocol for decryption, security, session, decompression and other processing.

    • New generation of network messages

The network messages are generated in accordance with the negotiated intranet application protocol, where encryption, security, session, and compression are possible.

    • Forwarding to a proxy server

Send the newly generated network message to the intranet server (possibly Web server, FTP server, mail server).

    • Receiving network messages

Network messages that accept feedback from the intranet server.

    • Pretreatment

This is based on the negotiation of a good extranet application protocol for encryption, security, session, compression and other processing.

    • Resource Output Module

This generates a message that satisfies the requirements of the extranet application protocol and sends it to the other end of the extranet connection (user agent).

Common Reverse proxy Server

Their names you must remember: Ngnix,iis,apache.

1.5. Summary

Conceptually: Web servers are programs that provide WWW services, web containers are frameworks for developers, Web application servers are much richer, and can be used by vendors who typically follow certain industry standards and custom extensions, or with the lightweight assembly of open source components Reverse proxy Server has outstanding performance in enterprise application, and it has the advantages of solving centralized security, load balancing and so on. Now that the boundaries of these four concepts are blurred, look at this table to find out:

There are two ideas about whether Kerstrel is a Web container:

1. Since Kerstrel does not provide a framework for writing applications, it is not a container, and ASP. NET core is a container because it provides a framework for developing applications and provides a WEB application (mvc,web API) Runtime environment.

2. Kerstrel provides a running environment.

We welcome your strong point of view and help us to clarify the concept of this ASP.

Data references

"1" https://en.wikipedia.org/wiki/Web_server
"2" http://www.cnblogs.com/vipyoumay/p/5853694.html
"3" https://zh.wikipedia.org/wiki/%E5%8F%8D%E5%90%91%E4%BB%A3%E7%90%86

Web server, Application server, Web container, reverse proxy server difference and contact

Related Article

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.