Springboot替换默认容器

springboot默认支持的容器有tomcat、jetty、undertow
在我们项目中替换掉了tomcat使用undertow容器,那么undertow容器是什么,为什么比tomcat更有优势


undertow简介

Undertow 是红帽公司开发的一款基于 NIO 的高性能 Web 嵌入式服务器
Undertow 被设计成为完全可嵌入式,所以也叫做可嵌入式容器,可以很好的嵌入在SpringBoot中


性能比对

使用jmeter进行压测比较
tomcat压测结果
在这里插入图片描述
在这里插入图片描述
将tomcat容器换成jetty容器进行测试
在这里插入图片描述
将jetty容器修改为undertow
在这里插入图片描述
在这里插入图片描述
从吞吐量看undertow要强于前两个

二、项目中使用undertow

1.引入依赖

在官网上可以看到undertow主要有两个版本
2.1
The current stable Servlet 4.0 branch, requires JDK8 or above

1.4
The current stable Servlet 3.1 branch, supports JDK7
可以根据自己的servlet和jdk版本进行选择,我们这里使用2.1版本

<dependency>
    <groupId>io.undertow</groupId>
    <artifactId>undertow-core</artifactId>
    <version>2.1.0.Final</version>
</dependency>

<dependency>
    <groupId>io.undertow</groupId>
    <artifactId>undertow-servlet</artifactId>
    <version>2.1.0.Final</version>
</dependency>

<dependency>
    <groupId>io.undertow</groupId>
    <artifactId>undertow-websockets-jsr</artifactId>
    <version>2.1.0.Final</version>
</dependency>
  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值