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

The characteristics and usage of Undertow

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

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

This article mainly explains the "characteristics and usage of Undertow". The content of the explanation is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "the characteristics and usage of Undertow".

Undertow

Undertow is a high performance Web embedded server based on NIO developed by Red Hat.

Characteristics of Untertow:

Lightweight: it is a Web server, but unlike traditional Web servers, it has a container concept. It consists of two core Jar packages that load a Web application that can be less than 10MB memory.

Servlet3.1 support: it provides support for Servlet3.1

WebSocket support: full support for WebSocket to meet a huge number of clients for Web applications

Nesting: it does not need a container, and you can quickly build a Web server through API

By default, Spring Cloud uses Tomcat as an embedded Servlet container, which can start a Spring Boot program of Tomcat and a Spring Boot program of Undertow. By comparing the VisualVM tool, we can see that the performance of Undertow is better than that of Tomcat.

Use Undertow

Add dependency

Org.springframework.boot

Spring-boot-starter-web

Org.springframework.boot

Spring-boot-starter-tomcat

Org.springframework.boot

Spring-boot-starter-undertow

Support for HTTP2

/ / add @ bean to the @ Configuration class

@ Bean

UndertowEmbeddedServletContainerFactory embeddedServletContainerFactory () {

UndertowEmbeddedServletContainerFactory factory = new UndertowEmbeddedServletContainerFactory ()

/ / other configurations can also be made here.

Factory.addBuilderCustomizers (builder-> builder.setServerOption (UndertowOptions.ENABLE_HTTP2, true))

Return factory

}

Configure Undertow

# Undertow log storage directory

Server.undertow.accesslog.dir

# whether to start the log

Server.undertow.accesslog.enabled=false

# Log format

Server.undertow.accesslog.pattern=common

# Log file name prefix

Server.undertow.accesslog.prefix=access_log

# Log file name suffix

Server.undertow.accesslog.suffix=log

# maximum size of HTTP POST request

Server.undertow.max-http-post-size=0

# set the number of IO threads, which mainly perform non-blocking tasks, which are responsible for multiple connections. By default, one thread is set for each CPU core

Server.undertow.io-threads=4

# blocking task thread pool. When performing a similar servlet request blocking operation, undertow will get threads from this thread pool. Its value setting depends on the load of the system.

Server.undertow.worker-threads=20

# the following configurations will affect buffer, which will be used for IO operations of server connections, similar to pooled memory management of netty

# the size of each buffer. The smaller the space is, the more fully utilized it is.

Server.undertow.buffer-size=1024

# the number of buffer allocated per zone, so the size of pool is buffer-size * buffers-per-region

Server.undertow.buffers-per-region=1024

# whether direct memory is allocated or not

Server.undertow.direct-buffers=true

Thank you for your reading, the above is the content of "the characteristics and usage of Undertow". After the study of this article, I believe you have a deeper understanding of the characteristics and usage of Undertow, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

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

Internet Technology

Wechat

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

12
Report