Distributions
Ubuntu
Fedora
CentOS
中文资源站
网易开源镜像站
xiongya5555
V2EX  ›  Linux

容器 cpu 占有率为什么异常升高?

  •  
  •   xiongya5555 · Jan 29, 2021 · 3137 views
    This topic created in 1956 days ago, the information mentioned may be changed or developed.
    使用同一个镜像运行容器,每个容器 2 核,当只有一个容器运行时,该容器 cpu 占有率始终为 40%,当有十二个容器运行时,每个容器 cpu 占有率始终为 120%,可能是什么原因?(网络,磁盘,GPU 都没跑满,容器内线程调用栈也看不出什么问题)
    18 replies    2021-01-31 23:13:03 +08:00
    laminux29
        1
    laminux29  
       Jan 30, 2021
    虚拟化由于其兼容问题的复杂度过高,永远都没办法 100%稳定。

    玩虚拟化,最好是找台同配置电脑或服务器,装 ESXi,拿来做参照基准,这样找问题会比较容易。

    找问题时,多用快照甚至克隆。每当你对虚机做了一小个更改,立马保存一个版本。通过不断对比版本,你就能发现,哪次在什么地方,做了什么更改,导致系统突然变得不稳定,或者系统的 CPU 使用率突然增高。找到问题出处后,再去分析,才容易得到结论。
    cheng6563
        2
    cheng6563  
       Jan 30, 2021 via Android
    是不是有健康检查
    owenliang
        3
    owenliang  
       Jan 30, 2021 via Android
    是不是服务器过载了呢
    BeautifulSoap
        4
    BeautifulSoap  
       Jan 30, 2021 via Android
    @laminux29 老哥,容器不是虚拟化
    nevin47
        5
    nevin47  
       Jan 30, 2021
    @laminux29 #1 虚拟化工程师表示被冒犯

    另外 Container 和 Hypervisor 是两个体系。。
    laminux29
        6
    laminux29  
       Jan 30, 2021
    @BeautifulSoap
    如果一定要掰字眼的话:
    1.
    Operating-system-level virtualization, also known as containerization, refers to an operating system feature in which the kernel allows the existence of multiple isolated user-space instances. Such instances, called containers,

    Hogg, Scott (2014-05-26). "Software Containers: Used More Frequently than Most Realize". Network World. Network World, Inc. Retrieved 2015-07-09.

    2.
    To do this, containers take advantage of a form of operating system (OS) virtualization in which features of the OS

    IBM Cloud Education (12 August 2019 ), "What are containers".
    laminux29
        7
    laminux29  
       Jan 30, 2021
    @nevin47

    1.没必要觉得被冒犯,VMware 公司的产品,功能与稳定性,目前太阳系第一。有时间建议了解一下这公司的发家史。

    2.我没说它们完全是一回事,我只是建议用 ESXi 作为参照基准。
    fuse
        8
    fuse  
       Jan 30, 2021 via iPhone
    哥哥来跟你们解释一下
    如何容器里面的任务,也就是干的活都一样的情况下

    cpu 使用变高,说明指令执行变慢了,perf ipc 查看

    为什么会变慢,原来缓存就给一个任务用,命中高,现在多人用,每个任务分到的就少,执行就慢

    系统总资源是一定的
    fuse
        9
    fuse  
       Jan 30, 2021 via iPhone
    当然也包括 cpu 内其他资源,共享,造成指令执行等待
    fuse
        10
    fuse  
       Jan 30, 2021 via iPhone
    你家房子就住你一个人,用厨房,上厕所都很快,
    但是住个 10 个人,你要上厕所,就要等别人上完
    cassyfar
        11
    cassyfar  
       Jan 30, 2021
    首先 top 确定是 service 占用 CPU 过大。然后对 service 作 CPU profiling 确定哪段程序占用 CPU 异常。
    xiongya5555
        12
    xiongya5555  
    OP
       Jan 30, 2021
    @fuse cpu 每个核心的缓存不是独立的吗?如果一个 cpu 中某个核心做的事情会引起另外一个核心变慢,那公有云服务厂商是怎么玩的?
    fuse
        13
    fuse  
       Jan 30, 2021 via iPhone
    @xiongya5555 l3 缓存不是独立的,共享的
    缓存只是其中一项,
    意思是,有些共享资源会拖慢别人运行

    楼主又没说邦核了没有,没绑不就到处跑吗
    xiongya5555
        14
    xiongya5555  
    OP
       Jan 30, 2021
    @fuse 抱歉,忘记说了,绑核了的
    xiongya5555
        15
    xiongya5555  
    OP
       Jan 30, 2021
    目前猜测是某个资源竞争访问太多,内核中有过多自旋锁造成的 cpu 升高
    fuse
        16
    fuse  
       Jan 31, 2021 via iPhone
    @xiongya5555 那你就要看是用户态还是内核
    tkl
        17
    tkl  
       Jan 31, 2021
    占有率始怎么算得 你连背景都没说清楚

    楼上的 fuse 感觉也是一本正经的乱猜胡说
    fuse
        18
    fuse  
       Jan 31, 2021 via iPhone
    @tkl 想听听你的高见,占有率怎么算
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2148 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 54ms · UTC 16:13 · PVG 00:13 · LAX 09:13 · JFK 12:13
    ♥ Do have faith in what you're doing.