Linux tuning for better CouchDB performance
Filesystem tuning
ext4
Mount options (or via /etc/fstab)
errors=remount-ro,noatime,nouser_xattr,barrier=0
Journal
(Replace sdXY
with your partition name)
Check if exists
sudo tune2fs -l /dev/sdXY | fgrep has_journal
Turn Off/On
Unmount filesystem (If root filesystem then mount read-only) and then:
tune2fs -O ^has_journal /dev/sdXY
xfs
Mount options (or via /etc/fstab)
noatime,nodiratime,logbufs=8,logbsize=256k,nobarrier
/etc/rc.local
(Replace sdX
with your device name)
echo noop > /sys/block/sdX/queue/scheduler
echo 4096 > /sys/block/sdX/queue/nr_requests
echo 4096 > /sys/block/sdX/queue/read_ahead_kb
echo 5 > /proc/sys/vm/dirty_background_ratio
echo 10 > /proc/sys/vm/dirty_ratio
echo 50 > /proc/sys/vm/vfs_cache_pressure
echo 1 > /proc/sys/vm/swappiness
echo 262144 > /proc/sys/vm/min_free_kbytes
echo madvise > /sys/kernel/mm/transparent_hugepage/enabled
echo 5000000 > /proc/sys/kernel/sched_migration_cost_ns
echo 0 > /proc/sys/kernel/sched_autogroup_enabled
echo performance | sudo tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
Apply the changes
sudo /etc/rc.local
or reboot
ionice
:warning: Using ionice
is effective if and only if IO scheduler uses an algorithm that takes
priorities into account. If you have followed this guide so far, using ionice
will have no effect
since you have set IO Scheduler to deadline
or noop
which doesn't use priorities.
Look for cfq
for a scheduler that works with priorities.
Giving CouchDB IO priority with ionice
: sudo ionice -p $(pidof beam.smp) -c 1 -n 0
.
This can also be done in a systemd
unit:
IOSchedulingClass=1
IOSchedulingPriority=0
Sources: