许多文件的 gluster 性能

Nic*_*ang 3 rsync glusterfs

只是想知道这样的表现是否正常。我正在将一个目录(大约 20 GB 的图像)同步到一个 gluster 卷(3 个节点,3 个副本,每个节点都在同一个 digitalocean 数据中心)中。

rsync --info=progress2 -r /var/www/app/_appdata/ /mnt
    251,670,295  62%  716.84kB/s    0:05:42 (xfr#5708, ir-chk=1257/7830)
Run Code Online (Sandbox Code Playgroud)

当我只复制一个大文件时,速度约为 30 MB/s。

当我复制一个充满许多文件的目录时,我得到大约 700 kB/s

知道为什么许多文件的速度这么慢吗?

小智 6

Rsync 对于 GlusterFS 来说是一个特别困难的工作负载,因为在默认情况下,它会执行 GlusterFS 的一些最坏情况操作。因此,从 rsync 获得最佳性能需要双方进行一些调整/调整。

\n\n

接下来介绍一下Rsync和GlusterFS配合使用时性能提升的痛点。

\n\n

首先

\n\n

rsync 和 GlusterFS 的主要问题是 rsync 在创建文件时使用 \xe2\x80\x9cwrite new then rename\xe2\x80\x9d 习惯用法。这意味着对于创建的每个文件,GlusterFS 都被迫重命名该文件,这是迄今为止最昂贵的文件操作 (FOP)。Gluster 开发人员添加了几个可调参数来帮助完成此工作负载:

\n\n

例如,rsync 和类似工具经常使用“写入新内容然后重命名”习惯用法,其中文件“xxx”实际上被写入为“.xxx.1234”,然后仅在其内容完全写入后才移动到位。为了使此过程更加高效,DHT 使用正则表达式将文件\xe2\x80\x99 名称的永久部分(在本例中为“xxx”)与可能的临时部分(前导“.”)分开。和尾随“.1234”)。这样,文件重命名后,它将位于正确的散列位置 \xe2\x80\x93,否则如果“xxx”和“.xxx.1234”散列不同 \xe2\x80,则\xe2\x80\x99 不会出现在\xe2\x80\x99 中\x93 并且不需要链接文件或广播查找。

\n\n

事实上,有两个正则表达式可用于此目的 \xe2\x80\x93cluster.rsync-hash-regexcluster.extra-hash-regex. 顾名思义,rsync-hash-regex 默认为 regex 使用的模式,而 extra-hash-regex 可以由用户设置以支持使用相同临时文件习惯用法的第二个工具。

\n\n

第二

\n\n

Rsync 默认的请求大小非常小,这也是 GlusterFS 的一个弱点。GlusterFS 在请求大小超过 64KB 时往往表现最佳;1MB 往往能提供最佳性能。当请求大小小于 4KB 时,情况确实开始恶化。Rsync 确实有一个可调参数来改变这种行为。它\xe2\x80\x99s 称为block-size. rsync\xe2\x80\x99s 的块大小默认为 2KB,这在与 GlusterFS 进行 rsync 或从 GlusterFS 进行 rsync 时确实会影响性能。例如:

\n\n
# rsync -vrah /gluster-mount/ /home/bturner/Downloads/ --progress -B=131072\n
Run Code Online (Sandbox Code Playgroud)\n\n

您还可以查看以下选项(请参阅 rsync 手册页):

\n\n
-W, --whole-file\n\nThis option disables rsync\xe2\x80\x99s delta-transfer algorithm, which causes all \ntransferred files to be sent whole. The transfer may be faster if this\noption is used when the bandwidth between the source and destination\nmachines is higher than the bandwidth to disk (especially when the \xe2\x80\x9cdisk\xe2\x80\x9d\nis actually a networked filesystem). This is the default when both\nthe source and destination are specified as local paths, but only if\nno batch-writing option is in effect.\n
Run Code Online (Sandbox Code Playgroud)\n\n

第三

\n\n

--inplace选项。该选项的行为与上述 rsync 正则表达式选项类似,只是它是在 rsync 端而不是 GlusterFS 端实现的。以下信息来自手册页:

\n\n
\xe2\x80\x93inplace update destination files in-place\n\nThis option changes how rsync transfers a file when its data needs to be\nupdated: instead of the default method of creating a new copy of the file\nand moving it into place when it is complete, rsync instead writes\nthe updated data directly to the destination file.\n
Run Code Online (Sandbox Code Playgroud)\n\n

在这里查看更多内容。

\n