Springboot實現(xiàn)將默認(rèn)tomcat容器改為Undertow
Undertow是啥
Undertow是Red Hat公司的開源產(chǎn)品, 它完全采用Java語言開發(fā),是一款靈活的高性能Web服務(wù)器,支持阻塞IO和非阻塞IO。
由于Undertow采用Java語言開發(fā),可以直接嵌入到Java項目中使用。同時, Undertow完全支持Servlet和Web Socket,在高并發(fā)情況下表現(xiàn)非常出色。
undertow 是一個服務(wù)器,在相同資源使用量的情況下 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次的并發(fā)測試
https://blog.csdn.net/weixin_42412601/article/details/107117736
接口:
@RequestMapping("testStudent")
@ResponseBody
public Object testStudent(){
return "test";
}
三次測試結(jié)果
吞吐量
tomcat 3679 3671 3706 undertow 5130 4943 5058
參數(shù)設(shè)置:
https://docs.spring.io/spring-boot/docs/current/reference/html/appendix-application-properties.html#server-properties

總結(jié)
以上為個人經(jīng)驗,希望能給大家一個參考,也希望大家多多支持腳本之家。
相關(guān)文章
Spring整合redis(jedis)實現(xiàn)Session共享的過程
這篇文章主要介紹了Spring整合redis(jedis)實現(xiàn)Session共享,需要的朋友可以參考下2018-06-06
解決SpringBoot使用@Value獲取不到y(tǒng)aml中配置值的問題
在最近的開發(fā)中遇到一個問題,使用@Value獲取yml文件中配置的屬性時始終獲取不到值,所以本文給大家詳細(xì)介紹了SpringBoot使用@Value獲取不到y(tǒng)aml中值的問題分析及解決方法,需要的朋友可以參考下2024-01-01
MybatisPlus 插入或更新數(shù)據(jù)時自動填充更新數(shù)據(jù)解決方案
本文主要介紹了MybatisPlus 插入或更新數(shù)據(jù)時自動填充更新數(shù)據(jù)解決方案,文中通過示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下2021-09-09
Apache DolphinScheduler實現(xiàn)自動化打包單機(jī)/集群部署詳解
這篇文章主要為大家介紹了Apache DolphinScheduler實現(xiàn)自動化打包單機(jī)/集群部署詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2023-09-09
java開源調(diào)度如何給xxljob加k8s執(zhí)行器
這篇文章主要介紹了java開源調(diào)度如何給xxljob加一個k8s執(zhí)行器,?xxljob?在設(shè)計上,抽象出了執(zhí)行器的接口,所以實現(xiàn)一個語言的執(zhí)行器并不復(fù)雜,這里主要探索下,如何利用k8s的pod?的能力,使用?xxljob?調(diào)度?pod?運行,實現(xiàn)一個通用的和語言無關(guān)的執(zhí)行器2022-02-02
Java實現(xiàn)用Freemarker完美導(dǎo)出word文檔(帶圖片)
這篇文章主要介紹了Java實現(xiàn)用Freemarker完美導(dǎo)出word文檔(帶圖片),具有一定的參考價值,感興趣的小伙伴們可以參考一下2017-07-07

