Performance tuning with System Control (sysctl) in Ubuntu
Sponsored Link
Important Note:- Editing sysctl.conf file might break your system this is for advanced users only
Procedure to follow
First you need to make a backup copy of /etc/sysctl.conf file using the following command
cp /etc/sysctl.conf /etc/sysctl.conf.back
Now edit the /etc/sysctl.conf file
sudo gedit /etc/sysctl.conf
Use which is suitable for you
Add the following lines to /etc/sysctl.conf if you have 512MB RAM or more
kernel.sem = 250 32000 100 128
kernel.shmall = 2097152
kernel.shmmax = 2147483648
kernel.shmmni = 4096
fs.file-max = 65536
vm.swappiness = 0
vm.vfs_cache_pressure = 50
If you have a fast broadband (UL 10Mbps / DL 10Mbps, my broadband connection speed) use the following setting
net.core.rmem_max = 16777216
net.core.wmem_max = 16777216
net.ipv4.tcp_rmem = 4096 87380 16777216
net.ipv4.tcp_wmem = 4096 65536 16777216
net.ipv4.tcp_no_metrics_save = 1
If you have a Wifi (such as IEEE 802.11 a/b/g) or a 3.5G modem, use the following setting
net.core.rmem_default = 524288
net.core.rmem_max = 524288
net.core.wmem_default = 524288
net.core.wmem_max = 524288
net.ipv4.tcp_wmem = 4096 87380 524288
net.ipv4.tcp_rmem = 4096 87380 524288
net.ipv4.tcp_mem = 524288 524288 524288
net.ipv4.tcp_rfc1337 = 1
net.ipv4.ip_no_pmtu_disc = 0
net.ipv4.tcp_sack = 1
net.ipv4.tcp_fack = 1
net.ipv4.tcp_window_scaling = 1
net.ipv4.tcp_timestamps = 1
net.ipv4.tcp_ecn = 0
net.ipv4.route.flush = 1
If you want to Prevent SYN attack use the following setting
net.ipv4.tcp_syncookies = 1
net.ipv4.tcp_max_syn_backlog = 2048
net.ipv4.tcp_synack_retries = 2
If you want to Disables packet forwarding use the following setting
net.ipv4.ip_forward=0
Increase the maximum number of open files use the following setting
fs.file-max = 100000
Save and exit the file
Now you need to run the following command to take your changes in to live
sudo sysctl -p
If you know any more tuning parameters please share with us.
pro-tip: don’t do this unless you know what you’re doing.
(or don’t complain when you have to reinstall)
Where can I find a brief explanation of what each of these settings does?
So how do you make these setting persist after reboot? Thanks for the article.
@joseph
When you edit sysctl.conf file and add those values and run sysctl -p this should be persist after reboot
You can find both a brief and a verbose explanation by using this really cool new site. Its really helpful for learning new things! http://www.google.com
No, it’s http://www.google.com/linux .
If you want to troll, do it the right way.
trolling the right way seems to be an oxymoron
i was found on other ubu tweak guide to set “vm.swappiness” to 0, not like in this solution to 1. So can someone tell me who have a better idea? Coz im confiused now :s
The best idea is to perform the all important first step – backup the file!
sudo cp /etc/sysctl.conf /etc/sysctl.conf.old
Maybe it’s just me, but I never ever recommend randomly changing tuning settings without knowing WHY you are changing them or what they’re supposed to improve. After you go and mess with all of this, what are the tests you can do to see the improvements? Would you open the hood of your car and randomly turn adjusting screws without knowing what you were doing?
??? If one messes up, is there a way to boot from cd, mount the hard drive, then cp /etc/sysctl.conf.back /etc/sysctl.conf
It can actually be made easier and without touching the original sysctl.conf. Just make file named something like 60-user.conf in the /etc/sysctl.d/ and put this stuff into it.
A complete sysctl.conf with kernel tuning and network security hardening optimizations for dedicated server systems at high-speed networks with loads of RAM and bandwidth available.
Optimised and tuned for high-performance web/ftp/mail/dns servers with high connection-rates.
Available here: https://klaver.it/linux/sysctl.conf
This comes up with Avast antivirus in Ubuntu. If you get an error when trying to start Avast! it is likely because the kernel.shmmax variable (shared memory max) is too small and needs to be increased:
$ sudo gedit /etc/sysctl.d/60-user.conf
In this file put:
# this is to make avast work
kernel.shmmax = 128000000
This will become active after reboot, but if you want to get it working before your next reboot:
$ sudo sysctl -p /etc/sysctl.d/60-user.conf
Ahoy!
Thank’s