Just to be clear, ever since I started watching videos on site B, I felt there was so much to learn. This article “server software literacy” is my feeling after watching a video of Brother Yang, such as Web server, HTTP server, application server these three concepts, I have seen many times, but if you have to tell me the difference between them, I have to speechless.
Also, I have used Tomcat, Nginx, Apache, Jetty and Undertow. What are the advantages and disadvantages among them? Had to continue speechless. There may be many friends like me, but the specific difference is really hard to tell, so I’m going to take this opportunity to learn with you. (I am the class representative, I am proud)
Let’s start with a Web server, which generally refers to a Web server that provides services to Web clients such as a browser (PC or mobile) to request or download data. The server uses HTTP (Hypertext Transfer Protocol) to communicate with the client browser, so we also call the Web server an HTTP server.
An application server is a software framework that provides an environment in which applications run. It is usually used to provide security, data, transaction support, load balancing and large distributed system management services for applications.
In my opinion, the line between Web server and application server has become very blurred, with the latter being more advanced, like the difference between the terms company and enterprise.
Common Web server software includes Nginx, Apache, and IIS. Common application server software includes WebLogic and JBoss. The former is more lightweight, while the latter is more heavyweight.
Next, we will talk about some common server software.
01, Tomcat,
As far as my programming career is concerned, Tomcat is the one I use the most. If Tomcat is installed successfully, you can visit http://127.0.0.1:8080 in your local browser to display its default home page, as shown below.
Tomcat is a Servlet container developed by the Jakarta project of the Apache Software Foundation. It implements support for servlets and JavaServer Pages (JSPS), and provides some unique functions as a Web server.
JSP is a dynamic web technology standard established by Sun Microsystems. A JSP can respond to a request sent by a client and dynamically generate a Web page of HTML, XML, or other formatted documents based on the request content, which is then returned to the requester.
JSP takes Java language as script language, provides service for user’s HTTP request, and can deal with complex business requirements together with other Java programs on the server. As a Java programmer in a third-tier city, I have to develop some small websites, which is why I use Tomcat the most.
02, Nginx
Nginx is a lightweight Web server that also supports reverse proxies. It is widely used in Internet projects because of its small memory footprint, extremely fast startup and high concurrency.
One of the more unfortunate things about Nginx is that its author igor Sessoyev is in prison.
According to the official test results, Nginx can support 50,000 parallel connections, which are used by well-known domestic companies, such as Baidu, JINGdong, Sina, netease, Tencent, Taobao and so on.
I don’t know if you have heard of the concept of virtual host, that is, in Web services there is an independent website site, this site corresponds to an independent domain name (may also be IP or port), with independent procedures and resources, can provide services for users to access independently.
There are three types of virtual hosts: domain-based virtual hosts, port-based virtual hosts, and IP-based virtual hosts.
Nginx can use a server{} tag to identify a virtual host, a Web service can have multiple virtual host tag pairs, that is, can support multiple virtual host sites. This point is very practical.
03, Apache
At first, I thought Apache was Tomcat. When I realized they were completely different, the logo was different.
Apache is generally referred to as Apache HTTP Server, which is a web Server software under the Apache Software Foundation (and Tomcat belong to the same foundation, so it is easy to confuse). Because of its cross-platform and security, it is widely used and is one of the most popular Web server software. It is fast, reliable, and extensible with a simple API.
I used Apache when I installed WordPress on the server. I didn’t know LAMP existed at that time, so I suffered a lot in the process of installation. The key was that I failed to install it successfully, which was a big embarrassment.
Finally, the installation was completed with the remote help of a fellow member of the Bronze Group, who works in PHP. LAMP was the one he told me about, and it was very foolproof to install, perfect for command-line resistance programmers like me.
LAMP is an acronym for a group of free software that runs dynamic websites or servers:
- Linux, operating system (common server software is installed on Linux, excellent performance)
- Apache web Server (Apache HTTP Server)
- MariaDB or MySQL, a database management system
- PHP, Perl, or Python, the scripting language
When used together, these software is very dynamic, and there are many variations of it. Another well-known one is LNMP, which uses Nginx instead of Apache.
04, Jetty
Jetty has many similarities to Tomcat, such as providing a runtime environment for JSPS and servlets. Jetty is written in the Java language and its API is distributed as a set of JAR packages.
Compared to Tomcat, Jetty can handle a large number of links simultaneously and hold them for a long time. For example, some Web chat applications, such as Taobao’s Wangwang Web version, are ideal for Jetty servers.
Jetty’s architecture is relatively simple. It has a basic data model called a Handler. Any component that can be extended can be added to the Server as a Handler, and Jetty manages these handlers for us.
05, Undertow
Undertow is a flexible, high-performance Web server written in Java that provides NIO based blocking and non-blocking apis.
Undertow can be embedded in an application or run independently with just a few lines of code, making it easy to get started. The following code is a simple Hello World server using Async IO:
public class HelloWorldServer {
public static void main(final String[] args) {
Undertow server = Undertow.builder()
.addHttpListener(8080."localhost")
.setHandler(new HttpHandler() {
@Override
public void handleRequest(final HttpServerExchange exchange) throws Exception {
exchange.getResponseHeaders().put(Headers.CONTENT_TYPE, "text/plain");
exchange.getResponseSender().send("Hello World");
}
}).build();
server.start();
}
}
Copy the code
After directly running, you can access it by typing http://localhost:8080 in the browser address bar. Doesn’t it feel very light?
For those of you who have developed small websites using JFinal, Undertow will be familiar, as JFinal’s default container has been switched to Undertow.
JFinal is an extremely fast WEB + ORM framework based on Java language. Its core design goal is rapid development, less code, simple learning, powerful, lightweight, easy to expand, and Restful.
06. Enterprise level
As for some other enterprise server software, I personally have not used, will not elaborate.
-
JBoss, which Was acquired by Red Hat and renamed WildFly.
-
WebLogic, oracle.
-
WebSphere, manufactured by IBM.
I believe that the partners to see the product side, know that these server software is enough heavyweight, are big, are big.
If you find this article helpful, please search “Silent King ii” on wechat and read it for the first time.
GitHub, portal ~, GitHub, portal ~, GitHub, Portal ~
I am the Silent King 2, a programmer with good looks but mediocre talent. Attention can improve learning efficiency, don’t forget three even ah, like, collect, message, I don’t pick, hee hee.