Addressing Degradation of Automated Download Speed (PowerShell): Removal of Optimization = No Change
We were running the WinSCP Module in PowerShell and when it slowed to 45 minutes, I tried re-coding using the WinSCP.exe so I could take advantage of the
-rawsettings
and implement some of the suggested solutions (most notably trying Blowfish and Sendbuf=0
). Our run of this code was also in the 40 minute range. The network team here worked with me to do a test from the same machine internally to one of their externally hosted (over the internet like our vendor) sites and we achieved ~20MB/sec in our test.
I'm hoping there is a setting I'm missing that will work with the specific host we are hitting as our test run demonstrated that we are not bandwidth limited.... and the vendor demonstrated they are handling multiple clients at the same time of day and pushing at high speed.
Code has been simplified to the pull portion only as none of the other logic is time consuming and the logs show the time is all related to download speed.
If there is a setting that will get us flying again, you'll have my gratitude (and some nerd points).
I've attached Session and Debug logs as well as the output log from our full script and a graph showing the behavior (it has been a slow progression of performance degradation).
Thanks in advance for any advice!!
WinSCP Version 5.9.1.0
Windows Server 2016 (v1607 OS Build 14393.7428)
Import-Module WinSCP $PDPRunType = "DAILY" # Added just for testing purposes $TodayDateString = Get-Date -Format "yyyyMMddhhmmss" $TodayDateShortStr = Get-Date -Format "yyyyMMdd" $PDPRootDir = "C:\Projects\PullDailyPDP" $WinSCPBinPath = "$PDPRootDir\Bin\WinSCP.exe" $SessionLog = "$LogDir\WinSCP_Session_$TodayDateString.txt" $DebugLog = "$LogDir\WinSCP_Debug_$TodayDateString.txt" $PMONDIRNAME = "PMONDIR" $F25UN = "UserName" $F25FingerPrint = "ssh-rsa 2048 xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx" $F25Site = "sftpSite.com" $F25PWSecure = Get-Content "C:\Projects\Credentials\VendorPull25.txt" | ConvertTo-SecureString $F25BSTR = [System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($F25PWSecure) $F25PW = [System.Runtime.InteropServices.Marshal]::PtrToStringAuto($F25BSTR) $TimeOutMin = 10 $TimeOutMinTS = New-Timespan -Minutes $TimeOutMin ## Set Up for Test $F25PullDir = "/USER/UserPath/PRIME/DAILY3I010" $BackupDirRoot = "E:\Backup\Daily" $DailyPDPDir = "E:\Prime\Daily" $LocalPMonFile = "$TodaysBkpDir\$PMONDIRNAME" $TodaysBkpDir = "$BackupDirRoot\$TodayDateShortStr" # # Set up WinSCP Options # $F25session = New-Object WinSCP.Session $F25sessionOptions = New-Object WinSCP.SessionOptions $F25transferOptions = New-Object WinSCP.TransferOptions # # WinSCP Session and Transfer Options # $F25session.ExecutablePath = $WinSCPBinPath $F25Session.DebugLogPath = $DebugLog $F25Session.SessionLogPath = $SessionLog $F25transferOptions.TransferMode = [WinSCP.TransferMode]::Binary $F25sessionOptions.Protocol = [WinSCP.Protocol]::Sftp $F25sessionOptions.HostName = $F25Site $F25sessionOptions.UserName = $F25UN $F25sessionOptions.Password = $F25PW $F25sessionOptions.SshHostKeyFingerprint = $F25FingerPrint $F25sessionOptions.Timeout = $TimeOutMinTS # # Raw settings to speed download MB/s # $F25sessionOptions.AddRawSettings("Cipher", "blowfish,aes,chacha20,aesgcm,3des,WARN,des,arcfour") $F25sessionOptions.AddRawSettings("PreserveDirectoryChanges", "0") $F25sessionOptions.AddRawSettings("SendBuf", "0") $F25sessionOptions.AddRawSettings("SshSimple", "0") $F25session.Open($F25sessionOptions) $Files2Pull = Get-Content -Path $LocalPMonFile If ($F25Session.Opened) { Foreach ($FileName in $Files2Pull) { $FileName = $FileName.Trim() $RemoteFile = "$F25PullDir/$FileName" $PullResult = Receive-WinSCPItem -WinSCPSession $F25Session -Path $RemoteFile -Destination $TodaysBkpDir -Remove } }