Home  >  Article  >  Java  >  What is the reason for prohibiting SpringBoot from using the Tomcat container in the project?

What is the reason for prohibiting SpringBoot from using the Tomcat container in the project?

PHPz
PHPzforward
2023-05-12 15:34:061298browse

Tomcat container in SpringBoot

SpringBoot can be said to be the most popular Java Web framework at present. It frees developers from cumbersome xml and allows developers to create a complete web service in a few minutes, greatly improving developers' work efficiency. Web container technology is an essential component of Web projects, because any Web project must rely on container technology to run.

In the SpringBoot framework, the one we use most is Tomcat, which is the default container technology of SpringBoot and is an embedded Tomcat.

SpringBoot settings Undertow

Java programmers should be very familiar with Tomcat technology. It is the most commonly used container technology for Web applications. Our earliest developed projects were basically deployed and run under Tomcat. So in addition to Tomcat containers, what other container technologies can we use in SpringBoot? That's right, it's the Undertow container technology in the title. SrpingBoot has completely inherited Undertow technology. We only need to introduce Undertow's dependencies, as shown in the figure below.

What is the reason for prohibiting SpringBoot from using the Tomcat container in the project?

What is the reason for prohibiting SpringBoot from using the Tomcat container in the project?

After configuration, we started the application and found that the container had been replaced with Undertow. So why do we need to replace Tomcat with Undertow technology?

Comparison of the pros and cons of Tomcat and Undertow

Tomcat is a lightweight Servlet container under the Apache Foundation, supporting Servlets and JSP. Tomcat has unique functions of web server, including Tomcat management and control platform, security bureau management and Tomcat valve. Tomcat itself contains an HTTP server, so it can also be regarded as a separate Web server. However, Tomcat and Apache HTTP server are not the same thing. Apache HTTP server is an HTTP web server implemented in C language. Tomcat is completely free and loved by developers.

Undertow is an open source product of Red Hat. It is developed entirely in Java language. It is a flexible and high-performance web server that supports blocking IO and non-blocking IO. Since Undertow is developed in Java language, it can be directly embedded into Java projects for use. At the same time, Undertow fully supports Servlet and Web Socket, and performs very well in high concurrency situations.

What is the reason for prohibiting SpringBoot from using the Tomcat container in the project?

We stress tested Tomcat and Undertow under the same machine configuration, and the test results obtained are as follows: QPS test result comparison: Tomcat

What is the reason for prohibiting SpringBoot from using the Tomcat container in the project?

Undertow

What is the reason for prohibiting SpringBoot from using the Tomcat container in the project?

Memory usage comparison:

Tomcat

What is the reason for prohibiting SpringBoot from using the Tomcat container in the project?

Undertow

What is the reason for prohibiting SpringBoot from using the Tomcat container in the project?

Through testing, it was found that Tomcat is relatively weak in high-concurrency systems. Under the same machine configuration and simulating an equal number of requests, Undertow is optimal in terms of performance and memory usage. And the new version of Undertow uses persistent connections by default, which will further improve its concurrent throughput capabilities. Therefore, if it is a highly concurrent business system, Undertow is the best choice.

The above is the detailed content of What is the reason for prohibiting SpringBoot from using the Tomcat container in the project?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:yisu.com. If there is any infringement, please contact admin@php.cn delete