Skip to content

Commit

Permalink
Convert p09 md to rst
Browse files Browse the repository at this point in the history
  • Loading branch information
rimelek committed Feb 20, 2021
1 parent 03b4cfe commit 7d2ae47
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 65 deletions.
3 changes: 1 addition & 2 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,6 @@ If it does not exist or empty, then set the value manually or run the script bel
All off the examples were tested with Docker 20.10.1. The version of Docker Compose was 1.27.4.
You can try with more recent versions but some behaviour could be different in the future.

* [p09](projects/p09/README.md): CPU limit test

.. toctree::
:maxdepth: 2
:caption: Projects:
Expand All @@ -90,3 +88,4 @@ You can try with more recent versions but some behaviour could be different in t
projects/p06
projects/p07
projects/p08
projects/p09
65 changes: 65 additions & 0 deletions docs/projects/p09.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
.. _petermaric/docker.cpu-stress-test: https://hub.docker.com/r/petarmaric/docker.cpu-stress-test

==============
CPU limit test
==============

We test the CPU limit in this example using an image based on `petermaric/docker.cpu-stress-test`_. Since that image is outdated, we create a new image similar to Peter Maric's work.

.. code:: bash
docker build -t localhost/stress .
Execute the following command to test a whole CPU core:

.. code:: bash
docker run -it --rm \
-e STRESS_MAX_CPU_CORES=1 \
-e STRESS_SYSTEM_FOR=30 \
--cpus=1 \
localhost/stress
Run "top" in an other terminal to see that the "stress" process uses 100% of one CPU.

Press Ctrl-C and execute the following command to test two CPU core and allow the container to use only 1 and a half CPU.

.. code:: bash
docker run -it --rm \
-e STRESS_MAX_CPU_CORES=2 \
-e STRESS_TIMEOUT=30 \
--cpus=1.5 \
localhost/stress
Use "top" again to see that the "stress" process uses 75% of two CPU.

You can test on one CPU core again and allow the container to use 50% of
a specific CPU core by setting the core index.

.. code:: bash
docker run -it --rm \
-e MAX_CPU_CORES=1 \
-e STRESS_SYSTEM_FOR=60 \
--cpus=0.5 \
--cpuset-cpus=0 \
localhost/stress
You can use top again, but do not forget to add the index column to the list:

* run "top"
* press "f"
* Select column "P" by navigating with the arrow keys
* Press "SPACE" to select "P"
* Press "ESC"

Now you can see the indexes in the column "P".

Press "1" to list all the CPU-s at the top of the terminal so you can see the usage of all the CPU-s.

Clean the project:

.. code:: bash
docker-compose down
63 changes: 0 additions & 63 deletions projects/p09/README.md

This file was deleted.

0 comments on commit 7d2ae47

Please sign in to comment.