HOWTO : Performance tuning on Ubuntu

This tutorial can be applied to Desktop and Server. Make sure you have at least 512MB RAM on your system beofre doing so.



Step 1 :



sudo nano /etc/sysctl.conf



Append the following lines at the end of the file.



kernel.sem = 250 32000 100 128

kernel.shmall = 2097152

kernel.shmmax = 2147483648

kernel.shmmni = 4096

# If you have more than 512MB RAM, use this setting (uncomment it and comment the setting just below)

fs.file-max = 262140

# If you have 512MB RAM or less, use this setting

#fs.file-max = 65535

vm.swappiness = 1

vm.vfs_cache_pressure = 50

vm.min_free_kbytes = 65536



net.core.rmem_default = 33554432

net.core.rmem_max = 33554432

net.core.wmem_default = 33554432

net.core.wmem_max = 33554432

net.ipv4.tcp_rmem = 10240 87380 33554432

net.ipv4.tcp_wmem = 10240 87380 33554432

net.ipv4.tcp_no_metrics_save = 1

net.ipv4.tcp_window_scaling = 1

#net.ipv4.tcp_timestamps = 1

#net.ipv4.tcp_sack = 1

#net.core.netdev_max_backlog = 5000

#net.ipv4.tcp_mem = 786432 1048576 26777216

net.ipv4.ip_local_port_range = 1024 65535

net.ipv4.tcp_max_tw_buckets = 360000



net.ipv4.tcp_max_orphans = 3276800

net.ipv4.tcp_tw_reuse = 1

net.ipv4.tcp_tw_recycle = 1

net.ipv4.tcp_syn_retries = 2

net.ipv4.tcp_synack_retries = 2

net.core.somaxconn = 32768

net.core.netdev_max_backlog = 32768

net.ipv4.tcp_max_syn_backlog = 65536

net.ipv4.tcp_mem = 94500000 915000000 927000000

net.ipv4.tcp_timestamps = 0

net.ipv4.tcp_fin_timeout = 15

#net.ipv4.tcp_sack = 0

net.ipv4.tcp_orphan_retries = 2

net.ipv4.conf.all.accept_redirects = 0

net.ipv4.conf.default.accept_redirects = 0

net.ipv4.conf.all.secure_redirects = 0

net.ipv4.conf.default.secure_redirects = 0

net.ipv4.conf.all.log_martians = 1

net.ipv4.conf.default.log_martians = 1

net.ipv4.conf.all.accept_source_route = 0

net.ipv4.conf.default.accept_source_route = 0

net.ipv4.conf.all.rp_filter = 1

net.ipv4.conf.default.rp_filter = 1

net.ipv4.tcp_syncookies = 1





Save and perform the following command.



sudo /sbin/sysctl -p



Step 2 :



sudo nano /etc/rc.local



Insert the following lines just before "exit 0". This requires to reboot the system to make it works.



echo 1024 > /sys/block/sda/queue/read_ahead_kb

echo 256 > /sys/block/sda/queue/nr_requests




Step 3 :



To do the following step is in your own risk. It works for ext4 only.



sudo nano /etc/fstab



add "discard,norelatime,noatime" just before "errors=remount-ro" and "defaults".



If there is any problem or error when applying the commands, please do not reboot the system. Correct the problem or typo before reboot. Otherwise, your system cannot be reboot.



sudo mount -a

sudo mount -o remount /




Step 4 :



You can now reboot your system if there is no error at Step 3.



That's all! See you.