แนวทางการ limit ZFS ARC

แนวทางการ limit ZFS ARC

กรณีเราติดตั้ง proxmox ด้วยระบบ ZFS ค่าทำงานเริ่มต้นของระบบคือ ใช้งาน memory 50% ของทั้งระบบ เพราะว่า ARC (Adaptive Replacement Cache) จำเป็นต้องนำไปใช้งาน เพื่อประสิทธิภาพของ IO เราก็จะเห็น memory usage วิ่งอยู่ 80% - 90% ตลอดเวลา

แนวทางแก้ไขคือ ต้องกำหนด max ARC แล้วจะกำหนดค่าเท่าไหร่?

  • ค่าเริ่มต้น 2GB
  • + 1GB ต่อการใช้งาน storage 1TB

ยกตัวอย่าง zfs pool ขนาด 2TB ก็ควรกำหนด 2GB+1GB+1GB = 4GB

echo "$[4 * 1024*1024*1024]" >/sys/module/zfs/parameters/zfs_arc_max
กำหนด zfs_arc_max
cat /sys/module/zfs/parameters/zfs_arc_max
เรียกค่าของ zfs_arc_max
nano /etc/modprobe.d/zfs.conf
แก้ไขไฟล์ zfs.conf
options zfs zfs_arc_max=4294967296
นำค่าที่ได้จาก cat zfs_arc_max มาใส่
update-initramfs -u -k all
ทำการ update initramfs

ตัวอย่างกำหนด max ARC (2GB)

arc_summary
คำสั่งดู ARC summary
arcstat
คำสั่งดู ARC stat 

ตอนนี้ memory usage ของตัว proxmox จะลดลงอย่างชัดเจน ไม่ได้วิ่ง 80% - 90% เหมือนก่อนหน้านี้แล้ว จบ!