Linux Tuning For SIP Routers – Part 2 (Disk Access)

.

Introduction

If your SIP router does statefull processing and write the state like transactions information to different backends like syslog and SQL, you have to optimize the access to the disk where the state will be stored. The state can also be the dialog information like call duration, call start time, and setup time.

In Part 1 i have talked about interrupts and IRQ tuning. In this part i will show you how to tune the access to the disk to optimize the performance of your SIP router. Here i have Fedora Red Hat operating system, and Ext4 file system.

File System Tuning

To know the file system of your operating system and the mount options, execute the command “cat /etc/fstab“. The output will be like this:

/dev/mapper/fedora_dhcppc7-root                                  /              ext4    defaults        1 1
UUID=a534d6c5-ec57-4854-9c2b-db3ec3e66286            /boot        ext4    defaults        1 2
/dev/mapper/fedora_dhcppc7-home                               /home       ext4    defaults        1 2
/dev/mapper/fedora_dhcppc7-swap                                swap        swap    defaults       0 0

Each line in this output contains the following fields separated by spaces or tabs: partition or storage device, mounting point, file system type, mount options, dump, and pass.

According to this, the file system type is ext4 and the mount options is the defaults. In my system the default mount options are (rw, suid, dev, exec, auto, nouser, and async).

  • The option async allows asynchronous write/read operations on the file system. If your system has sync instead of async, change it otherwise keep it. You can read more about mount options in the man page “man mount“.
  • There is an option called  “noatime” which means reading accesses to the file system will not cause an update to the atime information (access time information) of the accessed files. In other words no writes to the file system for files which are being read. This is useful in case there is state reading from the disk.

To remount the root partition (i.e. /) with the mount option “noatime”, do this as root:

# mount -o remount, noatime   /

To do that permanently, edit the file fstab “vi  /etc/fstab" and update the corresponding line. For example if you want to add the mount option “noatime”  to the root partition (i.e. /):

This line : /dev/mapper/fedora_dhcppc7-root /                    ext4    defaults        1 1

will be : /dev/mapper/fedora_dhcppc7-root /                       ext4    defaults, noatime        1 1

To check the change in mount options: # mount |grep noatime. You will get this:

/dev/mapper/fedora_dhcppc7-root on  /  type ext4 (rw,noatime,seclabel,data=ordered)

Journaling File System

It is a file system feature which allows to serially log the changes in the file system into a dedicated area before committing them to the main file system. If a crash occurred, Any lost data can be recreated and stored in the locations that would have been stored in if the system had not crashed. In real time application like SIP routing, using non-journaling file system enhances the performance by avoiding the delay caused by jourmaling. In Ext4 file system you can turn off journaling feature. Do this to disable journaling:

  • Boot from your Linux installation DVD. Select Troubleshooting –> Rescue a Fedora system. Here you have your file system unmounted.
    • Execute: sh-4.2# tune2fs -O ^has_journal /dev/sda1
    • sh-4.2# tune2fs -O ^needs_recovery /dev/sda1
    • sh-4.2# e2fsck -f /dev/sda1
    • Remove the DVD and reboot.
  • Check file system features (There should be no “has_journal” or “needs_recovery”): # debugfs -R features /dev/sda1. The output:

Filesystem features: ext_attr resize_inode dir_index filetype extent flex_bg sparse_super huge_file uninit_bg dir_nlink extra_isize

Swappiness

The swap is a special place on the hard disk. Linux kernel stores physical memory pages/chunks that are currently unused on the swap to free up that pages from the physical memory. Using the disk as an extension to RAM is called virtual memory (RAM + swap). In real time applications like SIP routing, these are recommended:

  • Use enough physical memory.
  • Disable the swap or make the swapping rare.

How often the kernel do swapping is controlled by kernel parameter “Swappiness”. This parameter can be set to value between 0 and 100. The default value is 60.  To decrease the response latency, we use low value 0-10.  The value 0 makes the kernel swap only to avoid out of memory condition.

To change the “swappiness” value temporarily to 10, do this as root:

  • # echo 10 > /proc/sys/vm/swappiness
  • To verify the change : # cat /proc/sys/vm/swappines

To change the “swappiness” value permanently to 10, do this as root:

  • Edit the file “sysctl.conf” : # vim /etc/sysctl.conf
  • Add this line to override the default: vm.swappiness = 10

Next

In the Next Part , I will talk about memory tuning to optimize SIP Routers.


 

Leave a comment