springboot中undertow初尝试

在springboot框架中,我们经常使用、使用最多的是tomcat容器,这是springboot默认的容器技术,而且是内嵌式的tomcat。同时,springboot也支持undertow容器,而且可以方便的用undertow替换tomat,undertow的性能和内存使用方面都优于tomcat。
Undertow是Red Hat公司的开源产品, 它完全采用Java语言开发,是一款灵活的高性能Web服务器,支持阻塞IO和非阻塞IO。由于Undertow采用Java语言开发,可以直接嵌入到Java项目中使用。同时, Undertow完全支持Servlet和Web Socket,在高并发情况下表现非常出色。
实例
1、pom文件

		<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、启动
默认tomcat
在这里插入图片描述

undertow
在这里插入图片描述
3、测试
在这里插入图片描述

springboot中可以使用默认的tomcat作为http服务,也可以用undertow作为http服务。在高并发业务场景中,undertow的性能优于tomcat,所以在高并发请求场景,不妨使用undertow,会发现系统性能会得到提升。
后续可以对tomcat和undertow采用并发请求工具压测一下,看看真实的运行数据。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值