Intro to using curl with Fastly



  • Peter Wohlers

    You can actually expand the -w "%{time_total}\n" timing switch to include dns lookup time, connect time, tls negotiation, etc.. to help pin down where bottlenecks are. I tend to just create an alias or call a bash script to bundle all of the juicy curl bits into a single command.

    e.g.: curl -w "\nLookup time:\t%{time_namelookup}\nConnect time:\t%{time_connect}\nPreXfer time:\t%{time_pretransfer}\nStartXfer time:\t%{time_starttransfer}\n\nTotal time:\t%{time_total}\n" -svo /dev/null -HFastly-Debug:1 --compress Will give you all your headers but the timings will put things like the following at the bottom:

    ``` Lookup time: 0.526 Connect time: 0.542 PreXfer time: 0.690 StartXfer time: 0.729

    Total time: 0.837 ```

    Comment actions Permalink
  • Rogier Mulhuijzen

    Even better, you can store such statistics format strings in files, and just reference the files.

    Example commandline:

    curl -w "@curl-format.txt" -so /dev/null --compressed

    My curl-format.txt looks like this: \n time_namelookup: %{time_namelookup}\n time_connect: %{time_connect}\n time_appconnect: %{time_appconnect}\n time_pretransfer: %{time_pretransfer}\n time_redirect: %{time_redirect}\n time_starttransfer: %{time_starttransfer}\n ----------\n time_total: %{time_total}\n \n

    But normally I use curl-format-compact.txt which looks like: DNS: %{time_namelookup} Connect: %{time_connect} AppConn: %{time_appconnect} preTX: %{time_pretransfer} Redir: %{time_redirect} TXstart: %{time_starttransfer} Total: %{time_total}\n

    Credit goes to this blog post:

    Comment actions Permalink

Please sign in to leave a comment.