Different top
s
What you're seeing is (likely) due to a difference in flavors of top
.
I'm going to take a wild guess and say that your Docker image is perhaps based on Alpine? The top
command in Alpine is busybox
. It reports the per-process CPU usage as a percentage of the TOTAL number of CPUs available (nCPUs * 100%).
This differs from most other flavors of top
, which report the per-process CPU usage as a percentage of a SINGLE CPU.
Both tops show same thing: ~50% usage on each CPU
The two top
screenshots are actually showing the same thing: node
process is using about 50% of each of the 2 CPUs.
Testing theory
We can test this with the following:
# This will max out 1 cpu of the system
docker run --name stress --rm -d alpine sh -c 'apk add stress-ng && stress-ng --cpu 1'
# This shows the busybox top with usage as ratio of total CPUs
# press 'c' in top to see the per-CPU info at the top
docker exec -it stress top
# This will install and run procps top, with usage as a ratio of single CPU
docker exec -it stress sh -c 'apk add procps && /usr/bin/top'
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…