Why do many springboot developers give up Tomcat and choose undertow

Time:2021-5-3

My official account:MarkerHub, Java website:https://markerhub.com

For more selected articles, please click:Java notes.md

Read by little hub:

The performance and memory usage of undertow are better than tomcat, which is why undertow is popular! You can also try to switch in the springboot project and its simple!


  • Author: Amada
  • toutiao.com/a6775476659416990212/

preface

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

At the same time, springboot also supports the undertow container. We can easily replace Tomcat with undertow, and the performance and memory usage of undertow are better than Tomcat. How can we use the undertow technology? This article will explain for you in detail.

Tomcat container in springboot

Springboot is the most popular java web framework. It saves developers from the heavy XML, allows developers to create a complete web service in a few minutes, and greatly improves the efficiency of developers. Web container technology is an indispensable part of Web project, because any web project must run with the help of container technology.

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

Springboot setting undertow

Java programmers should be very familiar with Tomcat technology, which is the most commonly used container technology for web applications. Our earliest development projects are basically deployed under Tomcat. In addition to Tomcat container, what container technology can we use in springboot?

Yes, it’s the undertow container technology in the title. Srpingboot has fully inherited the undertow technology. We only need to introduce the dependency of undertow, as shown in the figure below.

Why do many springboot developers give up Tomcat and choose undertow

Why do many springboot developers give up Tomcat and choose undertow

After configuration, we start the application and find that the container has been replaced with undertow.

So why do we need to replace Tomcat with undertow technology?

Comparison of Tomcat and undertow

Tomcat is a lightweight servlet container under Apache foundation, which supports servlet and JSP. Tomcat has the 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 is very popular among developers(http://134.175.97.123:8888/home?id=62))

Why do many springboot developers give up Tomcat and choose undertow

Undertow is an open source product of red hat company. It is fully developed in Java language. It is a flexible high-performance web server, supporting blocking IO and non blocking io. Because subtow is developed in Java language, it can be directly embedded into Java projects. At the same time, subtow fully supports servlet and web socket, and performs very well in the case of high concurrency.

Why do many springboot developers give up Tomcat and choose undertow

We test Tomcat and undertow under the same machine configuration, and the test results are as follows:

Comparison of QPS test results:

Tomcat

Why do many springboot developers give up Tomcat and choose undertow

Undertow

Why do many springboot developers give up Tomcat and choose undertow

Memory usage comparison:

Tomcat

Why do many springboot developers give up Tomcat and choose undertow

Undertow

Why do many springboot developers give up Tomcat and choose undertow

The test shows that Tomcat is relatively weak in high concurrency system. Under the same machine configuration, simulating the same number of requests, undertow is the best 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. Therefore, if it is a high concurrency business system, undertow is the best choice.

last

In spingboot, we can use Tomcat as HTTP service or undertow instead. Undertow is better than Tomcat in high concurrency scenarios. Therefore, if our system is highly concurrent, you might as well use undertow, and you will find that your system performance will be greatly improved.

Recommended reading

Java notes.md

Great! This Java website has all kinds of projects! https://markerhub.com

The up Master of the B station, Java is really good!

Recommended Today

Large scale distributed storage system: Principle Analysis and architecture practice.pdf

Focus on “Java back end technology stack” Reply to “interview” for full interview information Distributed storage system, which stores data in multiple independent devices. Traditional network storage system uses centralized storage server to store all data. Storage server becomes the bottleneck of system performance and the focus of reliability and security, which can not meet […]