{{< details >}}
- Tier: 基础版,专业版,旗舰版
- Offering: 私有化部署
{{< /details >}}
文件系统性能对整体极狐GitLab 性能有很大影响,特别是在读取或写入 Git 仓库时。这些信息有助于根据已知的良好和不良现实系统来基准测试文件系统性能。
在讨论文件系统性能时,最大的关注点是网络文件系统 (NFS)。然而,即使一些本地磁盘也可能有较慢的 I/O。本文中的信息可以用于这两种情况。
执行基准测试
使用 fio
进行基准测试
您应该使用 Fio 来测试 I/O 性能。此测试应在 NFS 服务器和与 NFS 服务器通信的应用节点上运行。
安装方法:
- 在 Ubuntu 上:
apt install fio
。 - 在
yum
管理的环境中:yum install fio
。
然后运行以下命令:
fio --randrepeat=1 --ioengine=libaio --direct=1 --gtod_reduce=1 --name=test --bs=4k --iodepth=64 --readwrite=randrw --rwmixread=75 --size=4G --filename=/path/to/git-data/testfile
这将在 /path/to/git-data/testfile
中创建一个 4 GB 的文件。它在文件中以 75%/25% 的比例进行 4 KB 的读写操作,同时进行 64 次操作。测试完成后,请务必删除该文件。
输出因安装的 fio
版本而异。以下是 fio
v2.2.10 在网络固态硬盘 (SSD) 上的示例输出:
test: (g=0): rw=randrw, bs=4K-4K/4K-4K/4K-4K, ioengine=libaio, iodepth=64
fio-2.2.10
Starting 1 process
test: Laying out IO file(s) (1 file(s) / 1024MB)
Jobs: 1 (f=1): [m(1)] [100.0% done] [131.4MB/44868KB/0KB /s] [33.7K/11.3K/0 iops] [eta 00m:00s]
test: (groupid=0, jobs=1): err= 0: pid=10287: Sat Feb 2 17:40:10 2019
read : io=784996KB, bw=133662KB/s, iops=33415, runt= 5873msec
write: io=263580KB, bw=44880KB/s, iops=11219, runt= 5873msec
cpu : usr=6.56%, sys=23.11%, ctx=266267, majf=0, minf=8
IO depths : 1=0.1%, 2=0.1%, 4=0.1%, 8=0.1%, 16=0.1%, 32=0.1%, >=64=100.0%
submit : 0=0.0%, 4=100.0%, 8=0.0%, 16=0.0%, 32=0.0%, 64=0.0%, >=64=0.0%
complete : 0=0.0%, 4=100.0%, 8=0.0%, 16=0.0%, 32=0.0%, 64=0.1%, >=64=0.0%
issued : total=r=196249/w=65895/d=0, short=r=0/w=0/d=0, drop=r=0/w=0/d=0
latency : target=0, window=0, percentile=100.00%, depth=64
Run status group 0 (all jobs):
READ: io=784996KB, aggrb=133661KB/s, minb=133661KB/s, maxb=133661KB/s, mint=5873msec, maxt=5873msec
WRITE: io=263580KB, aggrb=44879KB/s, minb=44879KB/s, maxb=44879KB/s, mint=5873msec, maxt=5873msec
注意此输出中的 iops
值。在此示例中,SSD 每秒执行 33,415 次读操作和 11,219 次写操作。旋转磁盘可能产生每秒 2,000 次和 700 次读写操作。
简单基准测试
{{< alert type=”note” >}}
此测试较为简单,但如果系统上没有 fio
,则可以使用它。即使在此测试中获得良好结果,也可能由于读取速度和其他因素而性能较差。
{{< /alert >}}
以下单行命令提供文件系统写入和读取性能的快速基准测试。这会将 1,000 个小文件写入执行目录中,然后读取相同的 1,000 个文件。
- 切换到适当的 仓库存储路径 的根目录。
-
为测试创建临时目录,以便稍后可以删除:
mkdir test; cd test
-
运行命令:
time for i in {0..1000}; do echo 'test' > "test${i}.txt"; done
-
要基准测试读取性能,请运行命令:
time for i in {0..1000}; do cat "test${i}.txt" > /dev/null; done
-
删除测试文件:
cd ../; rm -rf test
time for ...
命令的输出如下所示。重要的指标是 real
时间。
$ time for i in {0..1000}; do echo 'test' > "test${i}.txt"; done
real 0m0.116s
user 0m0.025s
sys 0m0.091s
$ time for i in {0..1000}; do cat "test${i}.txt" > /dev/null; done
real 0m3.118s
user 0m1.267s
sys 0m1.663s
根据与多个客户的经验,此任务应在 10 秒内完成,以指示良好的文件系统性能。