zoukankan      html  css  js  c++  java
  • 8.docker的系统资源限制

    一、 概述

    默认docker容器使用的memory资源和CPU资源是没有限制的,但是我们可以在docker run的时候通过选项去限制,具体参考官方文档。

    [root@node1 ~]# docker run --help
        --kernel-memory bytes            Kernel memory limit
    -m, --memory bytes                   Memory limit
        --memory-reservation bytes       Memory soft limit
        --memory-swap bytes              Swap limit equal to memory plus swap: '-1' to enable unlimited swap
        --memory-swappiness int          Tune container memory swappiness (0 to 100) (default -1)
        --oom-kill-disable         Disable OOM Killer 
       --oom-score-adj int              Tune host's OOM preferences (-1000 to 1000)
    --cpu-period int Limit CPU CFS (Completely Fair Scheduler) period --cpu-quota int Limit CPU CFS (Completely Fair Scheduler) quota --cpu-rt-period int Limit CPU real-time period in microseconds --cpu-rt-runtime int Limit CPU real-time runtime in microseconds -c, --cpu-shares int CPU shares (relative weight) --cpus decimal Number of CPUs --cpuset-cpus string CPUs in which to allow execution (0-3, 0,1) --cpuset-mems string MEMs in which to allow execution (0-3, 0,1)

     操作系统进程管理子系统中,最重要的组件之一,进程调度器(scheduler)。docker1.13以前版本配置使用CFS scheduler(Completely Fair Scheduler 完全公平调度器),在docker1.13及以后版本,也可以使用realtime scheduler。

    进程:CPU密集型,IO密集型。

    Tips:尽量不要以管理员账号运行容器,并且应该做好资源限制。

    二、示例

    [root@node1 ~]# docker pull lorel/docker-stress-ng  #压测工具
    [root@node1 ~]# docker run --name stress --rm lorel/docker-stress-ng:latest stess --help #查看工具的帮助
    [root@node1 ~]# docker run --name stress --rm -m 256m  lorel/docker-stress-ng:latest stess --help :latest stess --vm 2  #压测内存
    [root@node1 ~]# docker top stress  #查看stress容器内运行进程的资源使用情况
    [root@node1 ~]# docker stats    # 查看所有容器资源使用的动态变化
    [root@node1 ~]# docker run --name stress --rm --cpus 0.5  lorel/docker-stress-ng:latest stess --cpu 4  #压测从CPU
    [root@node1 ~]# docker top stress
    [root@node1 ~]# docker stats
  • 相关阅读:
    根据判断PC浏览器类型和手机屏幕像素自动调用不同CSS的代码
    c#抓取网页内容乱码的解决方案
    C#中使用正则表达式提取超链接地址的集中方法
    sql server日期时间转字符串
    DataGridView直接导出EXCEL
    sql数据库删除表的外键约束(INSERT 语句与 FOREIGN KEY 约束"XXX"冲突。该冲突发生于数据库"XXX",表"XXX", column 'XXX)
    C#抓取页面时候,获取页面跳转后的地址
    HttpWebRequest 抓取页面异常处理办法
    JQuery的Ajax跨域请求的解决方案
    mysql 事物ACID和隔离级别
  • 原文地址:https://www.cnblogs.com/cmxu/p/11695329.html
Copyright © 2011-2022 走看看