4

I am running fabric to automate deployment. It is painfully slow.

My local environment:

(somenv)bob@sh ~/code/somenv/somenv/fabfile $  > uname -a
Darwin sh.local 12.4.0 Darwin Kernel Version 12.4.0: Wed May  1 17:57:12 PDT 2013; root:xnu-2050.24.15~1/RELEASE_X86_64 x86_64

My fab file:

#!/usr/bin/env python

import logging
import paramiko as ssh
from fabric.api import env, run

env.hosts = [ 'examplesite']
env.use_ssh_config = True
#env.forward_agent = True
logging.basicConfig(level=logging.INFO)
ssh.util.log_to_file('/tmp/paramiko.log')

def uptime():
  run('uptime')

Here is the portion of the debug logs:

(somenv)bob@sh ~/code/somenv/somenv/fabfile $  > date;fab -f /Users/bob/code/somenv/somenv/fabfile/pefabfile.py uptime
Sun Aug 11 22:25:03 EDT 2013
[examplesite] Executing task 'uptime'
[examplesite] run: uptime
DEB [20130811-22:25:23.610] thr=1   paramiko.transport: starting thread (client mode): 0x13e4650L
INF [20130811-22:25:23.630] thr=1   paramiko.transport: Connected (version 2.0, client OpenSSH_5.9p1)
DEB [20130811-22:25:23.641] thr=1   paramiko.transport: kex algos:['ecdh-sha2-nistp256', 'ecdh-sha2-nistp384', 'ecdh-sha2-nistp521', 'diffie-hellman-grou

It takes 20 seconds before paramiko is even starting the thread. Surely, Executing task 'uptime' does not take that long. I can manually log in through ssh, type in uptime, and exit in 5-6 seconds. I'd appreciate any help on how to extract mode debug information. I made the changes mentioned here, but no difference.

3 Answers 3

8

Try:

env.disable_known_hosts = True

See: https://github.com/paramiko/paramiko/pull/192 & Slow public key authentication with paramiko

1
  • 1
    It works!!! My fabric program speeds up from tens of minutes to seconds!! Thank you so much!
    – godice
    Apr 24, 2016 at 3:43
0

Maybe it is a problem with DNS resolution and/or IPv6.

A few things you can try:

  • replacing the server name by its IP address in env.hosts
  • disabling IPv6
  • use another DNS server (e.g. OpenDNS)
0

For anyone looking at this post-2014, paramiko, which was the slow component when checking known hosts, introduced a fix in March 2014 (v1.13), which was allowed as requirement by Fabric in v1.9.0, and backported to v1.8.4 and v1.7.4.

So, upgrade !

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.