Theodoros Bourchas
2015-04-23 15:50:43 UTC
Hi all,
My server has persistent SSH connections with N hosts.
I would like to issue periodical execution of remote commands in parallel
to these N hosts, and this should be done as fast as possible. This means
that after the execution of the first task per host, the next execution of
the same task should be faster.
I tried without and with Fabric:
a) Without Fabric and editing .ssh/config with the following lines
Host *
ControlMaster auto
ControlPath ~/.ssh/sockets/%r@%h-%p
ControlPersist 600
I issued a simple command and counted the time of the first 2 executions:
*1st execution*:
*time ssh -i <key> ***@lP -p port uname -s*
Linux
real 0m0.456s
user 0m0.024s
sys 0m0.005s
*2nd execution*
*time ssh -i <key> ***@lP -p port uname -s*
Linux
real 0m0.105s
user 0m0.005s
sys 0m0.008s
As you can see the second one is faster because there is not another
authentication delay and the session is established over the existing TCP
connection.
B)With Fabric, I edited a fabfile with the same task, as following:
env.user = 'user'
env.key_filename = 'key'
env.hosts = 'host_string'
@task
def askName():
run("uname -s")
and I executed :
*time fab askName*
[localhost:45864] Executing task 'askName'
[localhost:45864] run: uname -s
[localhost:45864] out: Linux
[localhost:45864] out:
Done.
Disconnecting from localhost:45864... done.
real 0m1.063s
user 0m0.332s
sys 0m0.085s
The delay with Fabric is double the first execution duration without Fabric
and it is constant all the times. I would really appreciate if someone can
point me out why Fabric is slower? [a new TCP connection is established at
every task execution?]
I would like to use the parallel execution feature of Fabric, but if the
delay per host is such bigger, do u think that using thread/host and
without fabric would be faster?
I would be glad if anyone has found a solution to a similar issue with
Fabric, or can redirect me to another solution.
Thank you in advance,
Best,
Theodoros
My server has persistent SSH connections with N hosts.
I would like to issue periodical execution of remote commands in parallel
to these N hosts, and this should be done as fast as possible. This means
that after the execution of the first task per host, the next execution of
the same task should be faster.
I tried without and with Fabric:
a) Without Fabric and editing .ssh/config with the following lines
Host *
ControlMaster auto
ControlPath ~/.ssh/sockets/%r@%h-%p
ControlPersist 600
I issued a simple command and counted the time of the first 2 executions:
*1st execution*:
*time ssh -i <key> ***@lP -p port uname -s*
Linux
real 0m0.456s
user 0m0.024s
sys 0m0.005s
*2nd execution*
*time ssh -i <key> ***@lP -p port uname -s*
Linux
real 0m0.105s
user 0m0.005s
sys 0m0.008s
As you can see the second one is faster because there is not another
authentication delay and the session is established over the existing TCP
connection.
B)With Fabric, I edited a fabfile with the same task, as following:
env.user = 'user'
env.key_filename = 'key'
env.hosts = 'host_string'
@task
def askName():
run("uname -s")
and I executed :
*time fab askName*
[localhost:45864] Executing task 'askName'
[localhost:45864] run: uname -s
[localhost:45864] out: Linux
[localhost:45864] out:
Done.
Disconnecting from localhost:45864... done.
real 0m1.063s
user 0m0.332s
sys 0m0.085s
The delay with Fabric is double the first execution duration without Fabric
and it is constant all the times. I would really appreciate if someone can
point me out why Fabric is slower? [a new TCP connection is established at
every task execution?]
I would like to use the parallel execution feature of Fabric, but if the
delay per host is such bigger, do u think that using thread/host and
without fabric would be faster?
I would be glad if anyone has found a solution to a similar issue with
Fabric, or can redirect me to another solution.
Thank you in advance,
Best,
Theodoros