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

XHTML introductory tutorial: Use of list tags

Lists are used to list a series of similar or rela...

Detailed explanation of the process of building an MQTT server using Docker

1. Pull the image docker pull registry.cn-hangzho...

Detailed steps for using AES.js in Vue

Use of AES encryption Data transmission encryptio...

Disabled values ​​that cannot be entered cannot be passed to the action layer

If I want to make the form non-input-capable, I se...

SMS verification code login function based on antd pro (process analysis)

Table of contents summary Overall process front e...

A detailed introduction to Tomcat directory structure

Open the decompressed directory of tomcat and you...

Detailed explanation of JavaScript's built-in Date object

Table of contents Date Object Creating a Date Obj...

Linux uses iftop to monitor network card traffic in real time

Linux uses iftop to monitor the traffic of the ne...

How to implement the King of Glory matching personnel loading page with CSS3

Those who have played King of Glory should be fam...

Detailed tutorial on building nextcloud private cloud storage network disk

Nextcloud is an open source and free private clou...

20 Signposts on the Road to Becoming an Excellent UI (User Interface) Designer

Introduction: Interface designer Joshua Porter pub...

How to automatically deploy Linux system using PXE

Table of contents Background Configuring DHCP Edi...

Docker image analysis tool dive principle analysis

Today I recommend such an open source tool for ex...

jQuery Ajax chatbot implementation case study

Chatbots can save a lot of manual work and can be...