首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >Kubernetes上的Java Spring网络流量:尽管配置了资源,始终[或-http-epoll-1],[或-http-epoll-2],[或-http-epoll-3],[或-http-epoll-4]]

Kubernetes上的Java Spring网络流量:尽管配置了资源,始终[或-http-epoll-1],[或-http-epoll-2],[或-http-epoll-3],[或-http-epoll-4]]
EN

Stack Overflow用户
提问于 2022-05-07 03:52:29
回答 1查看 354关注 0票数 0

关于Java11SpringWebflow 2.6.6+ web应用程序的小问题,请使用Kubernetes进行封装和部署。

从web应用程序应用程序日志中,我看到了如下内容:

代码语言:javascript
运行
复制
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位,不少,也不多。

我试过:

代码语言:javascript
运行
复制
  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-”。

谢谢

EN

Stack Overflow用户

回答已采纳

发布于 2022-05-08 00:43:37

默认情况下,WebFlux使用Netty作为下划线web服务器。下面是Netty如何确定池Netty - LoopResources中线程数的方法

代码语言:javascript
运行
复制
/**
* 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应用程序来验证

代码语言:javascript
运行
复制
class TestCpu {
    public static void main(String[] args) {
       int processors = Runtime.getRuntime().availableProcessors();
       System.out.println("CPU cores: " + processors);
  }
}
票数 1
EN
查看全部 1 条回答
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/72149369

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档