Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save cricketnest/1caef8b33e5a12f094d621a1cda46184 to your computer and use it in GitHub Desktop.

Select an option

Save cricketnest/1caef8b33e5a12f094d621a1cda46184 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