Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to set Undertow in SpringBoot

2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

Today, the editor will share with you the relevant knowledge points about how to set Undertow in SpringBoot. The content is detailed and the logic is clear. I believe most people still know too much about this knowledge, so share this article for your reference. I hope you can get something after reading this article. Let's take a look at it.

Tomcat Container in SpringBoot

SpringBoot is arguably the most popular Java Web framework at present. It rescues developers from the heavy xml and allows developers to create a complete Web service in a few minutes, which greatly improves the productivity of developers. Web container technology is an essential part of the Web project, because any Web project needs to run with container technology.

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

SpringBoot sets Undertow

Java programmers should be very familiar with Tomcat technology, which is the most commonly used container technology for Web applications. Most of our earliest projects are deployed and run under Tomcat, so what other container technologies can we use in SpringBoot besides Tomcat containers?

Yes, it is the Undertow container technology in the title. SrpingBoot has completely inherited the Undertow technology, we only need to introduce the dependency of Undertow, as shown in the following figure.

Once configured, 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 advantages and disadvantages between Tomcat and Undertow

Tomcat is a lightweight Servlet container under the Apache fund that supports Servlet and JSP. Tomcat has the unique functions of Web server, including Tomcat management and control platform, security bureau management and Tomcat valve, etc. Tomcat itself contains a HTTP server, so it can also be treated as a separate Web server.

However, Tomcat and ApacheHTTP servers are not the same thing. ApacheHTTP servers are HTTP Web servers implemented in C language. Tomcat is completely free and is loved by developers. (the latest frequently asked enterprise interview questions and answers in 2020)

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

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

Comparison of QPS test results:

Tomcat

Undertow

Memory usage comparison:

Tomcat

Undertow

Through testing, it is found that in high concurrency systems, Tomcat is relatively weak. Under the same machine configuration, 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. Therefore, if it is a highly concurrent business system, Undertow is the best choice.

These are all the contents of the article "how to set up Undertow in SpringBoot". Thank you for reading! I believe you will gain a lot after reading this article. The editor will update different knowledge for you every day. If you want to learn more knowledge, please pay attention to the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report