Spring Boot Container Select Undertow instead of Tomcat

Source: Internet
Author: User
Tags http post memory usage

The Spring boot inline container supports Tomcat, Jetty, Undertow. Why Choose Undertow.

Here is an article, time released on January 26, 2017:
Tomcat vs. Jetty vs. Undertow:comparison of Spring Boot Embedded Servlet Containers
This article provides a detailed test of the performance and memory usage of the Spring boot application under three containers, including complete test code and test flow. proves that the undertow is the best in performance and memory usage. use Undertow instead of Tomcat in spring boot

1. maven Example:

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId> spring-boot-starter-web</artifactid>
    <exclusions>
        <exclusion>
            <groupId> Org.springframework.boot</groupid>
            <artifactId>spring-boot-starter-tomcat</artifactId>
        </exclusion>
    </exclusions>
</dependency>
<dependency>
    < Groupid>org.springframework.boot</groupid>
    <artifactid>spring-boot-starter-undertow</ Artifactid>
</dependency>

2. Configuration Undertow,application.yml Example:

server.undertow.accesslog.dir= # undertow Access log directory.
Server.undertow.accesslog.enabled=false # Enable Access log.
Server.undertow.accesslog.pattern=common # Format pattern for access logs. Server.undertow.accesslog.prefix=access_log.
# Log file name prefix.
Server.undertow.accesslog.rotate=true # Enable Access log rotation.
Server.undertow.accesslog.suffix=log # log file name suffix.
server.undertow.buffer-size= # Size of each buffer in bytes.
server.undertow.buffers-per-region= # Number of buffer per region.
server.undertow.direct-buffers= # Allocate buffers outside the Java heap.
server.undertow.io-threads= # Number of I/O threads to create for the worker.
Server.undertow.max-http-post-size=0 # Maximum size in bytes of the HTTP post content. server.undertow.worker-threads= # Number of worker threads.

3. Use Undertow to monitor multiple port examples:

 @Bean public Undertowembeddedservletcontainerfactory embeddedservletcontainerfactory () {
    Undertowembeddedservletcontainerfactory factory = new Undertowembeddedservletcontainerfactory (); Factory.addbuildercustomizers (New Undertowbuildercustomizer () {@Override public void customize (Builder b
        Uilder) {Builder.addhttplistener (8080, "0.0.0.0");
    }

    });
return factory; }

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.