[2015.5.3-2] file.recurse with lots of small files on windows minions very slow
I'm trying to sync a node application with text and binary files (images etc) to about 200 minions. The application is made up of 1159 files,282 folders and 17MB of data.
My node.sls file contains the following,
file.recurse:
- source: salt://win/sync/nodejs
- include_empty: True
I'm finding the initial file synchronization speed to be quite slow, about 10 minutes per minion. The copy command seems to process each file at a time. Our minions connect back to the sever over 3G, so latency might be an issue.
Lots of small half duplex data (or handshaking) over 3G will dramatically increase the processing time - each packet adding 120-300ms of latency.
If each file needs a separate command, then on initial copy without payload it would be over two minutes. (I'm sure there are additional command exchanges)
My guesstimate command exchange 1159 files x 120 ms the process would take 139080ms or (2.318 minutes)
Can the minions start multiple downloads sessions to the server?
Can the content be compressed into a single file, transmitted and decompressed the other side? I saw windows zip support is still under development.
Will the system diff binary files or transfer them?
@getabc, thanks for the report. A workaround you could try is to run an initial state that only sends an archive of the files and directories, unpack it, and then file.manage them thereafter. My thought is that this is an interesting scalability issue that we could encounter in many other use cases. What do you think, @whiteinge and @UtahDave?
@jfindlay archived file sounds like a great solution, but I believe not currently available with windows minions #12992
@getabc, what about using git or similar to serve the files on the minion? You would also have to install git on the minion.
@getabc, if you need to, you could send the files in as a zip archive and then cmd.run unzip them in place.
@jfindlay any plans to enable archive.unzip on windows minions?
@getabc, you should ask @twangboy what his workload is like. :-) I imagine that it would not be too difficult. @lorengordon or @eliasp may also know how to do this.
I haven't implemented any unzip functionality from within salt, but I've done it in PowerShell several times with a few variations. Below is my most recent variation. If python has a mechanism for calling out to .NET functions, it probably wouldn't be too bad to convert it to a custom module. Or could rewrite this as a one-liner and just use cmd.run wrapped in a jinja macro.
function Expand-ZipFile {
[CmdLetBinding()]
Param(
[Parameter(Mandatory=$true,Position=0,ValueFromPipeLine=$true,ValueFromPipeLineByPropertyName=$true)] [string[]] $FileName,
[Parameter(Mandatory=$true,Position=1,ValueFromPipeLine=$false,ValueFromPipeLineByPropertyName=$false)] [string] $DestPath,
[Parameter(Mandatory=$false,Position=2,ValueFromPipeLine=$false,ValueFromPipeLineByPropertyName=$false)] [switch] $CreateDirFromFileName
)
PROCESS {
foreach ($file in $FileName) {
if (!(Test-Path "$file")) {
throw "$file does not exist"
}
Write-Verbose "Unpacking zip archive: ${file}"
if ($CreateDirFromFileName) { $DestPath = "${DestPath}\$((Get-Item $file).BaseName)" }
$null = New-Item -Path $DestPath -ItemType Directory -Force -WarningAction SilentlyContinue
$Shell = new-object -com shell.application
$Shell.namespace($DestPath).copyhere($Shell.namespace("$file").items(), 0x14)
Write-Output (Get-Item $DestPath)
}
}
}
https://github.com/saltstack/salt-windows-dev/blob/develop/Modules/zip-module.psm1
https://stackoverflow.com/questions/28043589/how-can-i-compress-zip-and-uncompress-unzip-files-and-folders-with-batch
The archive module has been rewritten to use native python for dealing with zip files. I haven't tested it personally, but archive.unzip may work on Windows now. The state is archive.extracted
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
If this issue is closed prematurely, please leave a comment and we will gladly reopen the issue.