Quil Parallel Nodes Guide

A guide on how to combine your nodes power into one for improved rewards.

IMPORTANT: Backup your store files before committing to this change.

Requirements:

Configuration

  • Open your config.yml file in the /node/.config folder

  • Under Engine category fill the dataWorkerMultiaddrs section with the list of the IPs of your nodes like so:

 dataWorkerMultiaddrs: [
    "/ip4/192.168.1.112/tcp/40001",
    "/ip4/192.168.1.112/tcp/40002",
    "/ip4/192.168.1.112/tcp/40003",
    "/ip4/192.168.1.121/tcp/40001",
    "/ip4/192.168.1.121/tcp/40002",
    "/ip4/192.168.1.121/tcp/40003",
    "/ip4/192.168.1.121/tcp/40004",
    "/ip4/192.168.1.123/tcp/40001",
    "/ip4/192.168.1.123/tcp/40002",
    "/ip4/192.168.1.123/tcp/40003",
    "/ip4/192.168.1.123/tcp/40004"
 ]
  • Above is the setup for an 3 x (4 cores) - 12 cores total, 1 core is reserved for task scheduling - machine clusters, note 40001 - 40004, with more cores increment the port 40005... 40006... and so on.

    NOTE: 1 core is reserved for scheduling tasks on the first machine. Therefore only 3 data workers are listed on the dataWorkerMultiaddrs configuration for the first node.

  • Apply this configuration to all the nodes in the cluster.

Run

To run nodes in parallel, you need a custom script. Copy the code below and save it as para.sh to the /node folder.

#!/bin/sh
DIR_PATH=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P )

os=$1
architecture=$2
startingCore=$3
maxCores=$4
pid=$$
version=$5
crashed=0

start_process() {
  pkill node-*
  if [ $startingCore == 0 ]
  then
    $DIR_PATH/node-$version-$os-$architecture &
    pid=$!
  	if [ $crashed == 0 ]
  	then
    	maxCores=$(expr $maxCores - 1)
	fi
  fi

  echo Node parent ID: $pid;
  echo Max Cores: $maxCores;
  echo Starting Core: $startingCore;

  for i in $(seq 1 $maxCores)
  do
    echo Deploying: $(expr $startingCore + $i) data worker with params: --core=$(expr $startingCore + $i) --parent-process=$pid;
    $DIR_PATH/node-$version-$os-$architecture --core=$(expr $startingCore + $i) --parent-process=$pid &
  done
}

is_process_running() {
    ps -p $pid > /dev/null 2>&1
    return $?
}

start_process

while true
do
  if ! is_process_running; then
    echo "Process crashed or stopped. restarting..."
	crashed=$(expr $crashed + 1)
    start_process
  fi
  sleep 440
done
  • Run the data workers (slaves first, master last):

bash para.sh <os> <architecture> <starting core> <max cores> <version>
# Run node 3 Example - in machine 3 (Slave)
bash para.sh darwin arm64 7 4 1.4.20
# Run node 2 Example - in machine 2 (Slave)
bash para.sh darwin arm64 3 4 1.4.20
# Run node 1 Example - in machine 1 (Master)
bash para.sh darwin arm64 0 4 1.4.20

Loading...
highlight
Collect this post to permanently own it.
Kingcaster logo
Subscribe to Kingcaster and never miss a post.