Spring boot 中 Undertow 配置线程数

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/lovehouye/article/details/79205885

Spring boot 弃用tomcat 作为内嵌服务器,转用undertow

configurations {
    compile.exclude module: "spring-boot-starter-tomcat"
}
compile "org.springframework.boot:spring-boot-starter-undertow:$springBootVersion"

但是undertow 有一些设置

server:
    undertow:
      io-threads: 4
      worker-threads: ?

io-threads 好理解,根据CPU有几核,就填写几。但是worker-threads呢?网上的都写的,根据服务器负载来填。测试过,如果不填写,默认最少会初始化24个线程,最多60个线程。但是60个线程的时候,CPU和内存的占用对于4核8G的配置来说,也没有占用多少。难道是要挨个去尝试?试试多少个线程的时候,能把CPU和内存的利用率达到最高?

PS:附线程查询:Linux最大线程数限制及当前线程数查询

查询当前某程序的线程或进程数

pstree -p `ps -e | grep java | awk ‘{print $1}’` | wc -l

pstree -p 3660 | wc -l

猜你喜欢

转载自blog.csdn.net/lovehouye/article/details/79205885