Skip to content

Instantly share code, notes, and snippets.

@corporatepiyush
Last active December 16, 2020 10:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save corporatepiyush/55ecca29999cebbad2d58880cd376c90 to your computer and use it in GitHub Desktop.
Save corporatepiyush/55ecca29999cebbad2d58880cd376c90 to your computer and use it in GitHub Desktop.
Allocating CPU cores
// suppose you spawned 16 node processes on 16 core CPU
ps axf | grep node | grep -v grep | awk '{print $1}' | xargs -n 1 taskset -cp 0-15
// suppose you have n nginx worker process and m other nginx related processes and numbe rof CPU cores is m+n
count=0
for tbl in $(ps axf | grep nginx | grep -v grep | awk '{print $1}')
do
sudo taskset -cp $count $tbl
count=$((count+1))
done
// suppose you spawned n node processes on n core CPU
count=0
for tbl in $(ps axf | grep node | grep -v grep | awk '{print $1}')
do
taskset -cp $count $tbl
count=$((count+1))
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment