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