Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

openjdk:8-jre-alpine 导致 Runtime.getRuntime().availableProcessors() 获取到的 CPU 核数不准确 #4474

Closed
3 tasks done
klboke opened this issue Jul 20, 2022 · 0 comments

Comments

@klboke
Copy link
Contributor

klboke commented Jul 20, 2022

描述bug

openjdk:8-jre-alpine 镜像导致 Runtime.getRuntime().availableProcessors() 获取到的 CPU 核数不准确,如在 k8s 里定义 4C:

  resources:
    requests:
      cpu: 4
      memory: 6Gi
    limits:
      cpu: 4
      memory: 6Gi

程序里只返回了 2C
复现

通过如下步骤可以复现:

  1. 在 k8s 里启动 Apollo 服务, requests 、limits 都限制 4C
  2. 访问 Portal 的 /prometheus 接口
  3. 查看 system_cpu_count 指标,是否和 limits 吻合

期望
修改基础镜像为:openjdk:8-jre-slim

@klboke klboke changed the title openjdk:8-jre-alpine 镜像导致 Runtime.getRuntime().availableProcessors() 获取到的 CPU 核数不准确 openjdk:8-jre-alpine 导致 Runtime.getRuntime().availableProcessors() 获取到的 CPU 核数不准确 Jul 20, 2022
klboke added a commit to klboke/apollo that referenced this issue Jul 20, 2022
@klboke klboke closed this as completed Jul 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant