“The server is one of the devices that are often discussed in reality, because the server is closely related to modern life. According to the purpose of the server, the server can be subdivided into many categories. In order to improve everyone’s understanding of the server, this article will introduce three kinds of servers, they are: Web server, application server and HTTP server.
The server is one of the devices that are often discussed in reality, because the server is closely related to modern life. According to the purpose of the server, the server can be subdivided into many categories. In order to improve everyone’s understanding of the server, this article will introduce three kinds of servers, they are: Web server, application server and HTTP server.
The basic function of a web server is to provide web information browsing services. It only needs to support HTTP protocol, HTML document format and URL. Cooperate with the client’s web browser. Because the main protocol supported by the Web server is HTTP, the HTTP server and the WEB server are usually equal (Is there a web server that supports protocols other than HTTP, the author has not verified it), it is the same thing.
Application server (referred to as application server), let’s take a look at Microsoft’s definition of it: “We define an application server as “the underlying system software that executes shared business applications as a server.” Just like a file server provides many users Like files, the application server allows multiple users to use the application at the same time (usually the application created by the customer)”
In layman’s terms, the Web server serves pages so that the browser can browse, but the application server provides methods that the client application can call. To be precise, you can say: Web servers specialize in processing HTTP requests, but application servers serve business logic for applications through many protocols.
Taking Java EE as an example, the web server mainly processes static pages and acts as a Servlet container, interpreting and executing servlet/JSP, while the application server runs business logic, mainly EJB, JNDI and JMX API and other J2EE APIs. Contains functions such as transaction processing and database connection, so in enterprise-level applications, the functions provided by the application server are much more powerful than those provided by the WEB server.
With this definition, IIS, Apache, and Tomcat can all belong to Web servers, and Weblogic and WebSphere all belong to application servers.
Apache: Among web servers, Apache is a pure web server and is often paired with Tomcat. It has a strong ability to interpret HTML pages, but it cannot interpret the server-side script code (JSP/Servlet) embedded in the page.
Tomcat: The early Tomcat is a JSP/Servlet interpretation engine embedded in Apache Apache+Tomcat is equivalent to IIS+ASP. Later Tomcat is no longer embedded in Apache, and the Tomcat process runs independently of the Apache process. Moreover, Tomcat is already an independent Servlet and JSP container, business logic layer code and interface interaction layer code can be separated. Therefore, some people call Tomcat a lightweight application server.
IIS: Microsoft’s early IIS was a pure Web server. Later, it embeds the ASP engine and can interpret VBScript and JScript server-side code. At this time, it can double as an application server. Of course, it is incomparable with J2EE application server, but, in terms of function and principle, it can barely be called an application server. To be precise, it is a web server with a little application server function.
To sum up: Apache is a pure web server, and Tomcat and IIS can be called lightweight application servers or web servers with server functions because they have the ability to interpret and execute server-side code. Because Weblogic and WebSphere can provide powerful J2EE functions, they are undoubtedly absolute application servers. For Tomcat in the middle position, it can be used with the pure web server Apache, or it can be deployed together with the application server as an auxiliary to the application server.
Two, Tomcat and application server
So far, Tomcat has been regarded as the executor of Servlet/JSP API, the so-called Servlet container. However, Tomcat is not only that, it also provides the implementation mechanism of JNDI and JMX API. Nevertheless, Tomcat is still not an application server, because it does not provide support for most J2EE APIs.
It is very interesting that many current application servers usually use Tomcat as their Servlet and JSP API container. Because Tomcat allows developers to embed Tomcat into their applications just by adding a line of thanks. Unfortunately, many commercial application servers do not follow this rule.
For developers, if they are looking for the use of Servlet, JSP, JNDI and JMX technology to generate Java Web applications, choosing Tomcat is an excellent solution; but in order to find support for other J2EE APIs, then look for an application server or Using Tomcat as an auxiliary to the application server would be a good solution; the third way is to find independent J2EE API implementations, and then use them in combination with Tomcat. Although integration will bring related problems, this approach is the most effective. .
Three, Tomcat and Web server
Tomcat provides a container that supports Servlet and JSP operation. Servlet and JSP can generate dynamic web content according to real-time needs. As for the web server, Apache only supports static webpages, and it will be powerless to support dynamic webpages; Tomcat can serve both dynamic webpages and static webpages at the same time. Although it is not as fast as the usual web server and not as rich in functions as the web server, Tomcat has gradually expanded to support static content. Most web servers are written in low-level languages such as C, and take advantage of the characteristics of the corresponding platform. Therefore, the execution speed of Tomcat written in pure Java cannot be comparable to them.
Generally speaking, large sites are the combination of Tomcat and Apache. Apache is responsible for accepting all HTTP requests from clients, and then forwarding Servlets and JSP requests to Tomcat for processing. After Tomcat completes the processing, it sends the response back to Apache, and finally Apache returns the response to the client. And in order to improve performance, one apache can be connected to multiple tomcats to achieve load balancing.
Let’s talk about it in detail below:
1. Web Server
You know, the proxy Model of the Web server (delegaTIon model) is very simple. When a request (request) is sent to the Web server, it simply passes the request (request) to a program that can handle the request (translator’s note: server-side script). The Web server only provides an environment where the server-side program can be executed and the response (generated by the program) can be returned, without going beyond the scope of its functions. Server-side programs usually have functions such as transacTIon processing, database connecTIvity, and messaging.
Although the web server does not support transaction processing or database connection pooling, it can employ various strategies to achieve fault tolerance and scalability, such as load balancing and buffering. (caching). Clustering features (clustering-features) are often mistaken for only features specific to the application server.
2. The Application Server
According to our definition, as an application server, it exposes business logic to client applications through various protocols, including HTTP. The web server mainly processes the sending of HTML to the browser for browsing, while the application server provides access to business logic for client applications. The application uses this business logic as if you call a method of an object (or a function in a procedural language).
The client of the application server (including the graphical user interface (GUI)) may run on a PC, a Web server, or even other application servers. The information traveling back and forth between the application server and its client is not limited to simple Display marks. Instead, this information is program logic. It is precisely because this logic takes the form of data and method calls instead of static HTML that the client can use this exposed business logic as much as it wants.
In most cases, the application server exposes the business logic (to the client application) through the application program interface (API) of the component, such as an application based on J2EE (Java 2 Platform, Enterprise Edition) The EJB (Enterprise JavaBean) component model of the program server. In addition, the application server can manage its own resources, such as gate-keeping duties including security, transaction processing, resource pooling, and messaging. Just like a web server, the application server is configured with a variety of scalability and fault tolerance technologies.
3. Warning (Caveats)
Now, XML Web Services has confused the line between application server and Web server. By sending an XML payload (payload) to the server, the Web server can now process data and response (response) as much as the previous application server.
In addition, most application servers now include Web servers, which means that Web servers can be regarded as a subset of application servers. Although the application server includes the function of the Web server, developers rarely deploy the application server into this capacity (Translator’s Note: This function refers to both the functions of the application server and the Web server function). On the contrary, if necessary, they usually configure the Web server independently, one after the other with the application server. This separation of functions helps to improve performance (simple Web requests (request) will not affect the application server), separate configuration (dedicated Web server, cluster (clustering), etc.), and give the best product Choose to leave room.