Tutorial¶
This tutorial show how the use of Distem, a provider that prepare containers for you on Grid’5000.
Prerequisites¶
First of all, you have to reserve some nodes on Grid’5000, deploy a system on your nodes.
$ oarsub -t deploy -l "slash_22=1+nodes=2, walltime=02:00:00" -I
$ kadeploy3 -f $OAR_NODE_FILE -e debian9-x64-nfs -k
Then use the distem bootstrap:
$ distem-bootstrap --debian-version stretch
Distem-bootstrap installs Distem on the physical nodes and also starts a coordinator.
After the reservation done, you can get virtual IPs for your reservation :
$ frontend> g5k-subnets -sp
You will need this address for the experiment.
You have to download the image to create new containers for the experiment.
$ frontend> wget 'http://public.nancy.grid5000.fr/~amerlin/distem/distem-fs-jessie.tar.gz' -P ~/distem_img
It will create a new directory on your home with the jessie image.
Initialisation¶
To process to any experiments, you need to initialize nodes as the folowing code.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 | import time
import os
from statistics import mean, stdev
from distem import Distem
if __name__ == "__main__":
# The path to the compressed filesystem image
# We can point to local file since our homedir is available from NFS
FSIMG = "file:///home/USER/public/distem-fs-jessie.tar.gz"
# Put the physical machines that have been assigned to you
# You can get that by executing: cat $OAR_NODE_FILE | uniq
PNODES = ["pnode1", "pnode2"]
# The first argument of the script is the address (in CIDR format)
# of the virtual network to set-up in our platform
# This ruby hash table describes our virtual network
vnet = {
'name': 'testnet',
'address': ARGV[0]
}
nodelist = ['node-1', 'node-2']
# Read SSH keys
PRIV_KEY = os.path.join(os.environ["HOME"], ".ssh", "id_rsa")
PUB_KEY = "%s.pub" % PRIV_KEY
private_key = open(os.path.expanduser(PRIV_KEY)).read()
public_key = open(os.path.expanduser(PUB_KEY)).read()
sshkeys = {
"public" : public_key,
"private" : private_key
}
node1 = {
'name': nodelist[0],
'address': []
}
node2 = {
'name': nodelist[1],
'address': []
}
ifname = 'if0'
# Connect to the Distem server (on http://localhost:4567 by default)
distem = Distem()
# Start by creating the virtual network
distem.vnetwork_create(vnet['name'],
vnet['address'])
print("Network created")
# Creating one virtual node per physical one
# Create the first virtual node and set it to be hosted on
# the first physical machine
distem.vnode_create(nodelist[0],
{'host': PNODES[0]}, sshkeys)
print("Node %s created" %nodelist[0])
# Specify the path to the compressed filesystem image
# of this virtual node
distem.vfilesystem_create(nodelist[0],
{'image': FSIMG})
# Create a virtual network interface and connect it to vnet
distem.viface_create(nodelist[0],
'if0',
{'vnetwork': vnet['name'], 'default': 'true'})
print("Interface created")
# Create the first virtual node and set it to be hosted on
# the second physical machine
distem.vnode_create(nodelist[1],
{'host': PNODES[1]},
sshkeys)
print("Node %s created" %nodelist[1])
distem.vfilesystem_create(nodelist[1],
{'image': FSIMG})
# Create a virtual network interface and connect it to vnet
distem.viface_create(nodelist[1],
'if0',
{'vnetwork': vnet['name']})
print("Interface created")
# Starting the virtual nodes using the synchronous method
distem.vnodes_start(nodelist)
print("Nodes started")
|
Experiment¶
The experiment can be launched from the coordinator node as root. Below, the python code of the experiment.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 | import time
import os
from statistics import mean, stdev
from distem import Distem
if __name__ == "__main__":
# List of nodes
nodelist = ['node-1', 'node-2']
# List of latencies for the experiment
latencies = ['0ms', '20ms', '40ms', '60ms']
# Dictionnary for the experiment
results = {
'scp': {},
'rsync': {}
}
node1 = {
'name': nodelist[0],
'address': []
}
node2 = {
'name': nodelist[1],
'address': []
}
# Name of interface
ifname = 'if0'
# Number of iteration for the experiment
iteration = 5
# Connect to the Distem server (on http://localhost:4567 by default)
distem = Distem()
# Getting the -automatically affected- address of each virtual nodes
# virtual network interfaces
node1['address'] = distem.viface_info(node1['name'], ifname)['address'].split("/")[0]
node2['address'] = distem.viface_info(node2['name'], ifname)['address'].split("/")[0]
# Creating the files we will use in our experimentation
distem.vnode_execute(node1['name'],
'mkdir -p /tmp/src ; cd /tmp/src ; \
for i in `seq 1 100`; do \
dd if=/dev/zero of=$i bs=1K count=50; \
done'
)
# Printing the current latency
start_time = time.time()
distem.vnode_execute(node1['name'], 'hsjvdjq')
print("Latency without any limitations # %s" %(str(time.time() - start_time)))
desc = {
'output': {
'latency': {
'delay': []
}
}
}
# Starting our experiment for each specified latencies
print('Starting tests')
for latency in latencies:
results['scp'][latency] = []
results['rsync'][latency] = []
print("Latency #%s" %str(latency))
# Update the latency description on virtual nodes
desc['output']['latency']['delay'] = latency
distem.viface_update(node1['name'], ifname, desc)
distem.viface_update(node2['name'], ifname, desc)
for i in range(iteration):
print("\tIteration ## %s" %i)
# Launch SCP test
# Cleaning target directory on node2
distem.vnode_execute(node2['name'], 'rm -rf /tmp/dst')
# Starting the copy from node1 to node2
start_time = time.time()
cmd = "scp -rq /tmp/src %s:/tmp/dst" % node2["address"]
distem.vnode_execute(node1['name'],
cmd,
)
end_time = time.time()
import ipdb; ipdb.set_trace()
results['scp'][latency].append(time.time() - start_time)
# Launch RSYNC test
# Cleaning target directory on node2
distem.vnode_execute(node2['name'], 'rm -rf /tmp/dst')
# Starting the copy from node1 to node2
start_time = time.time()
distem.vnode_execute(node1['name'],
"rsync -r /tmp/src #{node2['address']}:/tmp/dst"
)
results['rsync'][latency].append(time.time() - start_time)
values = []
print("Rsync results :")
for latency in latencies:
print(results['rsync'][latency])
print("%s: [average=%s,standard_deviation=%s]"
%(latency, mean(results['rsync'][latency]), stdev(results['rsync'][latency])))
values = []
print("Scp results :")
for latency in latencies:
print(results['scp'][latency])
print("%s: [average=%s,standard_deviation=%s]"
%(latency, mean(results['scp'][latency]), stdev(results['scp'][latency])))
|