关于Java11SpringWebflow 2.6.6+ web应用程序的小问题,请使用Kubernetes进行封装和部署。
从web应用程序应用程序日志中,我看到了如下内容:
INFO [service,1bcce5941c742568,22c0ab2133c63a77] 11 --- [or-http-epoll-2] a.b.c.SomeClass : Some message from the reactive pipeline.
INFO [service,67cb40974712b3f4,15285d01bce9dfd5] 11 --- [or-http-epoll-4] a.b.c.SomeClass : Some message from the reactive pipeline.
INFO [service,5011dc5e09de30b7,f58687695bda20f2] 11 --- [or-http-epoll-3] a.b.c.SomeClass : Some message from the reactive pipeline.
INFO [service,8046bdde07b13261,5c30a56a4a603f4d] 11 --- [or-http-epoll-1] a.b.c.SomeClass : Some message from the reactive pipeline.
而且,我总是只能看到我认为代表的[or-http-epoll-1] [or-http-epoll-2] [or-http-epoll-3] [or-http-epoll-4]
:[reactor-http-epoll-N]
问题是,不管我从Kubernetes分配了多少CPU,始终都是这4位,不少,也不多。
我试过:
resources:
requests:
cpu: 1
memory: 1G
limits:
cpu: 2
memory: 2G
resources:
requests:
cpu: 4
memory: 4G
limits:
cpu: 6
memory: 6G
resources:
requests:
cpu: 10
memory: 10G
limits:
cpu: 10
memory: 10G
但再说一遍,总是只有这四个。
我很难理解这里的问题是什么,为什么我只能/总是使用4“或-http-epoll-”。
谢谢
发布于 2022-05-08 00:43:37
默认情况下,WebFlux使用Netty作为下划线web服务器。下面是Netty如何确定池Netty - LoopResources中线程数的方法
/**
* Default worker thread count, fallback to available processor
* (but with a minimum value of 4)
*/
int DEFAULT_IO_WORKER_COUNT = Integer.parseInt(System.getProperty(
ReactorNetty.IO_WORKER_COUNT,
"" + Math.max(Runtime.getRuntime().availableProcessors(), 4)));
下一个问题,当前的Runtime.getRuntime().availableProcessors()
是什么?
这取决于Java版本。直到Java 10,Docker上的应用程序才能看到计算机上的CPU,而不是容器中的CPU。
您可以创建一个简单的Java应用程序来验证
class TestCpu {
public static void main(String[] args) {
int processors = Runtime.getRuntime().availableProcessors();
System.out.println("CPU cores: " + processors);
}
}
https://stackoverflow.com/questions/72149369
复制相似问题