resource cpu memory

资源

  • 如何确定资源所需要的资源(cpu 和memory 的大小) 不好确定
  • 资源的多少取决于所处理的数据

memory

考虑的两个问题

  • 程序所需多少资源
  • 宿主机有多少资源可以提供
  • --memory 是对资源限制的参数

命令

--memory where unit = b, k, m or g

cpu 限制

相对比例限制 --cpu-share

  • docker run -d -P --name ch6_wordpress --memory 512m --cpu-shares 512 --user nobody --cap-drop net_raw --link ch6_mariadb wordpress:4.1
cpu-share container 1 container 2 container3
--cpu-share 512 1024 2048
proportion 28% 14% 57%
  • 计算总数,再计算所占有的比例

--cpu-period

CFS 完全公平调度周期(Limit the CPU CFS (Completely Fair Scheduler) period)

--cpu-quota cpu配额限制(CPU quota constraint)

  • --cpu-quota用来限制cpu的使用,设置完全公平调度能使用的的资源(Limit the CPU CFS (Completely Fair Scheduler) quota)
  • 50000 代表容器只能使用主机最多50%的资源
  • 多核cpu,必须调整该值

限制到某个cpu核心

docker run -d --cpuset-cpus 0 --name ch6_stresser dockerinaction/ch6_stresser

你可能感兴趣的:(resource cpu memory)