使用 get-childItem 进行 PSRemoting 性能开销 [英] PSRemoting performance overhead with get-childItem

查看:82
本文介绍了使用 get-childItem 进行 PSRemoting 性能开销的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这在 LOCALSERVER 上 2.3 分钟内完成:

This completes in 2.3 minutes on LOCALSERVER:

A: measure-command {$x = invoke-command {gci -recurse "C:\"}}

这在 38.4 分钟内在 LOCALSERVER 上完成:

This completes in 38.4 minutes on LOCALSERVER:

B: measure-command {$x = invoke-command -comp LOCALSERVER {gci -recurse "C:\"}}

为什么 B 这么慢?是不是因为输出被序列化为 XML,然后再次重组为对象",如此处所解释的,与 B 但不是A?还是有其他事情发生?

Why is B so much slower? Is it because the "output is being serialized to XML and then reconstituted into objects again", as explained here, with B but not A? Or is something else going on?

LOCALSERVER 运行带有 PS v3 的 Windows 2008R2.在这两种情况下,$x.count 都是 98973.

LOCALSERVER runs Windows 2008R2 with PS v3. In both cases $x.count is 98973.

我想更改现有脚本以使用 PSRemoting 在远程服务器上进行文件搜索.我认为如果在远程目标上运行 gci,搜索可能会更快完成.在少数测试中,使用 PSRemoting 搜索实际上运行的时间要长得多.我问回环方案只是因为它看起来是最简单的情况;我在远程服务器上看到了类似的结果.所以我会坚持这样的 UNC 路径搜索:

I was wondering about changing an existing script to use PSRemoting for file searches on remote servers. I thought the searches might finish sooner with gci running on the remote target. In a handful of tests, the searches actually ran much longer with PSRemoting. I'm asking about the loopback scenario only because it seemed like the simplest case; I saw similar results with remote servers. So I'll stick with UNC path searches like this:

gci -recurse \\REMOTESERVER\C$\folder

...除非这些结果看起来很奇怪,并且对我的远程配置或语法进行一些调整可能会大大提高性能?

...unless these results seem odd, and some adjustment to my remoting configuration or syntax might offer a big performance boost?

推荐答案

正如您所提到的,远程调用命令所需的时间还必须考虑反序列化您从远程管道返回的任何给定对象所需的时间(在您的情况是 C 驱动器的 FileSystemInfo 的整个树).我建议限制您在网络上序列化和反序列化的对象数量,并且在比较服务器性能时,也许可以考虑在您运行代码的机器上花费的时间:

As you mentioned, the time required to invoke the command remotely must also take into account the time needed to deserialize any given object you return from your remote pipeline (in your case the whole tree of FileSystemInfo of the C drive). I would suggest to limit the number of objects you serialize and deserialize over the network and, while comparing performances of your servers, perhaps consider the time taken from within the machine you are running the code on:

Invoke-Command -comp LOCALSERVER { Measure-Command { gci -recurse "C:\" } }

这篇关于使用 get-childItem 进行 PSRemoting 性能开销的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆