M
M
marliotto2017-03-20 13:34:15
MongoDB
marliotto, 2017-03-20 13:34:15

What are the implications of using nobarrier on SSD+XFS?

Debian 8 background
, MongoDB 3.2 3-server replica, SSD, XFS for /var/lib/mongodb, Raid 1 with mdadm.
The official MongoDB documentation advises using XFS to store database files.
I noticed that sometimes the database starts to slow down on secondary servers on the most primitive requests, a key request could take 5-10 seconds. The restart of the database helped and for some time everything worked well.
I found out that the disk is constantly overloaded and we have a high svctm, although there are very few actual operations and data being written.

iostat -dmx 3 5 sdb sda md4
Device:         rrqm/s   wrqm/s     r/s     w/s    rMB/s    wMB/s avgrq-sz avgqu-sz   await r_await w_await  svctm  %util
sdb               0.00   100.67    0.00  281.00     0.00     1.26     9.16     0.80    2.83    0.00    2.83   2.82  79.20
sda               0.00   100.67    0.00  281.00     0.00     1.26     9.16     0.86    3.07    0.00    3.07   3.06  85.87
md4               0.00     0.00    0.00  377.67     0.00     1.25     6.75     0.00    0.00    0.00    0.00   0.00   0.00

Device:         rrqm/s   wrqm/s     r/s     w/s    rMB/s    wMB/s avgrq-sz avgqu-sz   await r_await w_await  svctm  %util
sdb               0.00    94.00    0.00  277.00     0.00     1.22     9.00     0.81    2.94    0.00    2.94   2.88  79.73
sda               0.00    94.00    0.00  277.00     0.00     1.22     9.00     0.85    3.06    0.00    3.06   3.04  84.13
md4               0.00     0.00    0.00  364.67     0.00     1.20     6.71     0.00    0.00    0.00    0.00   0.00   0.00

Device:         rrqm/s   wrqm/s     r/s     w/s    rMB/s    wMB/s avgrq-sz avgqu-sz   await r_await w_await  svctm  %util
sdb               0.00    92.00    0.00  263.67     0.00     1.18     9.19     0.77    2.93    0.00    2.93   2.91  76.80
sda               0.00    92.00    0.00  263.67     0.00     1.18     9.19     0.78    2.95    0.00    2.95   2.94  77.60
md4               0.00     0.00    0.00  353.33     0.00     1.18     6.82     0.00    0.00    0.00    0.00   0.00   0.00

Moreover, on the master server, the load on the disk is 3-4 times less than on the secondary, although it should be the other way around, but also large. On reading there are inquiries to all servers in regular intervals.
Empirically, I came to the conclusion that the nobarrier option for XFS turned out to be a solution to the problem.
I also found several articles where it is just advised to use nobarrier for databases. ( https://www.slideshare.net/bytebot/tuning-linux-fo... https://docs.microsoft.com/en-us/azure/virtual-mac... )
iostat -dmx 3 5 sdb sda md4

Device:         rrqm/s   wrqm/s     r/s     w/s    rMB/s    wMB/s avgrq-sz avgqu-sz   await r_await w_await  svctm  %util
sdb               0.00   121.67   25.67  496.33     0.36     1.77     8.36     0.03    0.05    0.36    0.03   0.05   2.53
sda               0.00   121.67    0.33  496.33     0.00     1.77     7.32     0.03    0.05    0.00    0.05   0.04   2.00
md4               0.00     0.00   26.00  614.33     0.36     1.76     6.79     0.00    0.00    0.00    0.00   0.00   0.00

Device:         rrqm/s   wrqm/s     r/s     w/s    rMB/s    wMB/s avgrq-sz avgqu-sz   await r_await w_await  svctm  %util
sdb               0.00   115.00   34.33  463.67     0.47     1.69     8.91     0.03    0.07    0.27    0.05   0.07   3.47
sda               0.00   115.00    1.67  463.67     0.05     1.69     7.66     0.03    0.07    0.00    0.07   0.06   2.93
md4               0.00     0.00   36.00  577.00     0.52     1.69     7.38     0.00    0.00    0.00    0.00   0.00   0.00

Device:         rrqm/s   wrqm/s     r/s     w/s    rMB/s    wMB/s avgrq-sz avgqu-sz   await r_await w_await  svctm  %util
sdb               0.00   121.67   18.33  477.00     0.27     1.72     8.21     0.03    0.06    0.36    0.05   0.06   2.93
sda               0.00   121.67    1.00  477.00     0.08     1.72     7.70     0.03    0.07    0.00    0.07   0.06   2.80
md4               0.00     0.00   19.33  596.67     0.35     1.71     6.85     0.00    0.00    0.00    0.00   0.00   0.00

About nobarrier in the article tolstiyman.blogspot.ru/2013/07/etcfstab.html I read the following

barrier - using "barrier" (barrier) the file system forbids writing data blocks that came after the "barrier" until all preceding it will be transferred to disk; thus, high reliability is achieved at the expense of speed; by disabling the "barrier" (barrier=0, nobarrier), we speed up writing to the partition

What are the dire consequences of using nobarrier?
And why does the barrier affect performance so much?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Artem @Jump, 2017-03-20
Tag curated by

XFS is a very unreliable system when powered off.
Disabling nobarrier will increase speed by making efficient use of the in-memory cache, i.e. allowing lazy writes, but a sudden power outage or some kind of crash and you will lose data.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question