Implementation of Docker CPU Limit

Implementation of Docker CPU Limit

1. --cpu=<value>

1) Specify how much available CPU resources a container can use, but do not allow the container to always run on one or a few CPUs

2) For example, if the host has 2 CPUs and you set --cpus="1.5", you can declare that the container can use half of the CPUs, which is equivalent to setting --cpu-period="100000" and --cpu-quota="150000"

Start the centos base image in a 4-core server and set it to use 1 core CPU

docker run -itd --cpus="1" --name=centos centos7 /bin/bash

Enter the container and start the 4-core CPU test

View the resource status of the container

docker stats 08e1adecf3b7 

Check the server's CPU resources (because the test server is also in use by other services, the CPU resource ratio is extremely high, normally around 25%)

top 

2. --cpuset-cpus=<value>

1) Limit the container to use a specific CPU or core

2) Containers can use a comma-separated list or a hyphen-separated list of CPU ranges. The first CPU is numbered 0, and valid values ​​may be 0-3 (use the first, second, third, and fourth CPUs) or 1,3 (use the second or fourth CPU)

3. --cpu-period=<value>

1) Specify the CPU CFS scheduler period, which is used together with --cpu-quota.

2) The default value is 100000 microseconds (100 milliseconds). Most users do not change the default settings. For most use cases, --cpus is a more convenient alternative

4. --cpu-quota=<value>

1) Set COU CFS quota

2) For large number use cases, --cpus is a more convenient alternative

5. --cpu-shares

1) Set CPU weight. The default value is 1024.

2) When CPU resources are sufficient, it does not make sense to set CPU weights. Only when containers compete for CPU resources, CPU weights can make different CPU usage

This is the end of this article about the implementation of docker CPU limit. For more relevant docker CPU limit content, please search 123WORDPRESS.COM's previous articles or continue to browse the following related articles. I hope everyone will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • Docker and iptables and implementation of bridge mode network isolation and communication operations
  • Network management and network isolation implementation of Docker containers
  • How to isolate users in docker containers
  • How to use Docker to limit container resources
  • Docker Modify Docker storage location Modify container image size limit operation
  • How Docker limits the CPU available to containers
  • How to limit the memory available to a container in Docker
  • Introduction to Docker Isolation and Restriction Principles

<<:  CenOS6.7 mysql 8.0.22 installation and configuration method graphic tutorial

>>:  How to use Lottie animation in React Native project

Recommend

Detailed explanation of MySQL transaction isolation level and MVCC

Table of contents Transaction Isolation Level Pro...

mysql-5.7.28 installation tutorial in Linux

1. Download the Linux version from the official w...

How to detect file system integrity based on AIDE in Linux

1. AIDE AIDE (Advanced Intrusion Detection Enviro...

How to develop Java 8 Spring Boot applications in Docker

In this article, I will show you how to develop a...

CentOS 7 builds hadoop 2.10 high availability (HA)

This article introduces how to build a high-avail...

Understanding and solutions of 1px line in mobile development

Reasons why the 1px line becomes thicker When wor...

Two simple menu navigation bar examples

Menu bar example 1: Copy code The code is as foll...

Records of using ssh commands on Windows 8

1. Open the virtual machine and git bash window a...

Draw an iPhone based on CSS3

Result:Implementation Code html <div class=...

IE8 provides a good experience: Activities

Today I had a sneak peek at IE8 beta 1 (hereafter...

Is it necessary to give alt attribute to img image tag?

Do you add an alt attribute to the img image tag? ...

MySQL 8.0.21 installation tutorial with pictures and text

1. Download the download link Click download. You...

WeChat applet realizes left-right linkage

This article shares the specific code for WeChat ...