Springboot实现将默认tomcat容器改为Undertow
Undertow是啥
Undertow是Red Hat公司的开源产品, 它完全采用Java语言开发,是一款灵活的高性能Web服务器,支持阻塞IO和非阻塞IO。
由于Undertow采用Java语言开发,可以直接嵌入到Java项目中使用。同时, Undertow完全支持Servlet和Web Socket,在高并发情况下表现非常出色。
undertow 是一个服务器,在相同资源使用量的情况下 undertow 比 tomcat 有更好的吞吐量和较低的访问时延。
Springboot使用Undertow
依赖:
<!--移除tomcat依赖-->
<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>
<!--增加Untertow 依赖-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-undertow</artifactId>
</dependency>
使用jmeter做压力测试:10000次的并发测试
https://blog.csdn.net/weixin_42412601/article/details/107117736
接口:
@RequestMapping("testStudent")
@ResponseBody
public Object testStudent(){
return "test";
}
三次测试结果
吞吐量
tomcat 3679 3671 3706 undertow 5130 4943 5058
参数设置:
https://docs.spring.io/spring-boot/docs/current/reference/html/appendix-application-properties.html#server-properties

总结
以上为个人经验,希望能给大家一个参考,也希望大家多多支持脚本之家。
相关文章
springboot+vue实现websocket配置过程解析
这篇文章主要介绍了springboot+vue实现websocket配置过程解析,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下2020-04-04
mybatis-plus报错net.sf.jsqlparser.statement.select.SelectBody的
本文主要介绍了mybatis-plus报错net.sf.jsqlparser.statement.select.SelectBody的问题解决,具有一定的参考价值,感兴趣的可以了解一下2024-08-08
Java异常--常见方法--自定义异常--增强try(try-with-resources)详解
这篇文章主要介绍了Java异常--常见方法--自定义异常--增强try(try-with-resources)的相关知识,本文通过实例代码给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友可以参考下2023-03-03


最新评论