Deploy SPLAY on your cluster

This tutorial guides you through the deployment of SPLAY on your private cluster. The resulting configuration of the cluster will allow you to run hundreds/thousands (depending on your cluster) SPLAY daemons registered on a dedicated SPLAY controller, deployed on the same cluster. We assume there is full connectivity between each of the machines in the cluster, and no special routing configuration is required.

A. Install SPLAY Controller

In this first step we build and run the SPLAY controller that will orchestrate the daemons running on the cluster. Typically, one of the machines in your cluster should be dedicated to this task. To install and run the controller, please refer to the documentation in the install section. In the rest of this tutorial, we assume the following:
  1. controller machine's IP is
  2. you used ./controller_fork.rb to start your controller (to better support dozens of splayds)
  3. default controller settings have been preserved, in particular for the listening ports

B. Install SPLAY libraries

Install the SPLAY libraries and daemons in each of the physical machines of your cluster. Depending on your architecture, use the provided binaries or the source distribution, as explained here. Take note of the location of the installed libraries. If you installed the SPLAY deamon and libraries with the provided binaries under Linux/Ubuntu, this location is:
In the remainder of this tutorial, we assume this is the path where SPLAY libraries have been installed. It is easy to change this value in the following script by editing the value of SPLAY_INSTALL_DIR.

C. Local deployment

Now we will prepare each machine to host a given number of SPLAY daemons. Log into each one of the machines of your cluster to execute the following script :

function usage {
  echo "Usage: ./ machine_id splayds_per_machine splay_ctrl_ip"
  exit 1
if [ $# -lt 3 ] ; then
mkdir -p ~/local_splay_cluster/template/
cd ~/local_splay_cluster/template/
cp $SPLAY_INSTALL_DIR/jobd.lua .
cp $SPLAY_INSTALL_DIR/splayd.lua .
cp $SPLAY_INSTALL_DIR/splayd .
cp $SPLAY_INSTALL_DIR/settings.lua .
sed -i  s/"splayd.settings.key = \"local\""/"splayd.settings.key = \"host_NODE_NUMBER_GOES_HERE\""/ settings.lua
sed -i  s/" = \"my name\""/" = \"host_NODE_NUMBER_GOES_HERE\""/ settings.lua
sed -i  s/"splayd.settings.controller.ip = \"localhost\""/"splayd.settings.controller.ip = \"SPLAY_CTRL_IP\""/ settings.lua
sed -i s/print/--print/ settings.lua
sed -i s/os.exit/--os.exit/ settings.lua
sed -i s/"production = true"/"production = false"/ splayd.lua
cd ..
for ((i = 1 ; i <=$SPLAYDS_PER_MACHINE; i++ ))
  mkdir -p hosts/host_${BASE}_${i}
  cp -r template/* hosts/host_${BASE}_${i}
  sed s/NODE_NUMBER_GOES_HERE/${BASE}_${i}/ template/settings.lua > hosts/host_${BASE}_${i}/settings.lua
  sed -i  s/SPLAY_CTRL_IP/${SPLAY_CTRL_IP}/ hosts/host_${BASE}_${i}/settings.lua
for((j = 1 ; j <= $SPLAYDS_PER_MACHINE; j++))
	endport=$[$startport+499] #each splayd has 500 ports in range
	echo $startport $endport
	cd hosts/host_${BASE}_${j}/ 
	ctrlport=$[10999+$[$BASE % 10]] #first avail is 11000
	echo "Starting splayd host_${BASE}_${j} ${SPLAY_CTRL_IP} $ctrlport $startport $endport"
 	lua splayd.lua host_${BASE}_${j} ${SPLAY_CTRL_IP} $ctrlport $startport $endport &	
	cd ../../;
	sleep 0.1
Make the file executable and use it to start the number of daemons required by your deployment. For example:
chmod u+x splay-cluster-start
./ 1 50 

The first parameter of the script, in this example 1, indicates that you are deploying splayds in a machine with id 1. When you want to deploy more splayds on other machines, for instance on machine with id 2, you can execute:

./ 2 50 

Comments, questions and suggestions are welcome: