5/5 - (1 vote)

Tuning system parameters is used to increase the responsiveness and performance of the server. Do not rush to buy new hardware, maybe the main point is in software. To get started, analyze the load on the server and test your website for the load.

File system

First, make sure that you are using the ext4 file system:

df -T

# The output will be similar to:

Filesystem Type 1K-blocks Used Available Use% Mounted on

/ dev / vda1 ext4 20511592 2494920 16960708 13% /

tmpfs tmpfs 250152 0 250152 0% / dev / shm

tmpfs tmpfs 5120 0 5120 0% / run / lock

# Will be displayed in the Type column

If the file system is Ext3, then it is recommended to transfer it to Ext4 – a more productive and improved version.

Virtual memory

To perform time-consuming tasks, is used virtual memory (swap) – when RAM is full, part of the program is transferred to the hard drive. Thus, you can use more RAM than there is in the system.

The approach doesn’t make sense in systems with a large amount of RAM, especially since the RAM is faster than constant memory. It is also not recommended to use Swap on a server with SSDs – it significantly reduces the storage life (frequent write and read processes).

Ubuntu by default unloads data when RAM is 40% full.

To configure swap, use the vm.swappiness parameter, the value of which must be entered or edited in the sysctl.conf configuration file:

nano /etc/sysctl.conf

# Add line

vm.swappiness = 10

# The swap file is only activated if 10% of RAM is free

After that, you need to save the file and reboot the system. To verify that the new parameter is enabled, you need to execute:

sysctl -p

# Or

sysctl -a | grep vm.swappiness

# In the first case, it applies displays all the parameters of the file, in the second – selects the desired parameter among all possible variables

Caching can improve system performance. But if the web server performs a large number of read / write operations, then additional caching can slow down I / O.

Caching options can be configured:

$ sysctl -a | grep dirty

 vm.dirty_background_ratio = 10

 vm.dirty_background_bytes = 0

 vm.dirty_ratio = 20

 vm.dirty_bytes = 0

 vm.dirty_writeback_centisecs = 500

 vm.dirty_expire_centisecs = 3000

# Parameters responsible for dirty pages – data that needs to be written to disk or sent to swap

Parameters mean:

  • dirty_background_ratio – percentage of system memory that dirty pages can fill before background processes pdflush / flush / kdmflush write them to disk;
  • dirty_ratio – the maximum amount of system memory that dirty pages can fill;
  • dirty_background_bytes and vm.dirty_bytes – two previous points, only in bytes; parameters are interchangeable;
  • dirty_expire_centisecs – the time during that data can be stored in the cache, in our case, 30 s;
  • dirty_writeback_centisecs – how often pdflush / flush / kdmflush processes check the cache.

The amount of data that is waiting for recording can be viewed like this:

cat / proc / vmstat | egrep "dirty | writeback"

 nr_dirty 878

 nr_writeback 0

 nr_writeback_temp 0

# 878 dirty pages awaiting recording

To reduce the size of the cache for reducing the possibility of losing important data during a crash and minimize possible write / read delays, you must edit the vm.dirty_background_ratio and vm.dirty_ratio parameters:

vm.dirty_background_ratio = 5

vm.dirty_ratio = 10

# Values ​​are written by sysctl.conf


A mixed IPv4 / IPv6 environment can interrupt network-connected programs due to unintended protocol interactions. For example, by failure to connect apt or ssh to an IPv6 network, device incompatibility.

To disable IPv6:

sudo sh -c 'echo 1> / proc / sys / net / ipv6 / conf / all / disable_ipv6'

# Temporarily disable IPv6 on all interfaces

And to permanently disable the protocol, you need to edit the /etc/sysctl.conf file:

# Disable on all interfaces

net.ipv6.conf.all.disable_ipv6 = 1

# Disabling on a specific interface

net.ipv6.conf.eth0.disable_ipv6 = 1

# To apply the new parameters, just enter sudo sysctl -p /etc/sysctl.conf


Background processes can seriously load system memory. The sysv-rc-conf utility will help you here:

sudo aptitude install sysv-rc-conf

# Tool installation

sysv-rc-conf allows you to disable unnecessary services to speed up and optimize system resources.

After a clean installation, Ubuntu Server contains a minimum of services, only the most necessary. But if the server is used for a long time, then the list of processes can be extensive and will depend on the programs that you yourself installed.

If the desktop version is used, then here is a small list of services that can be disabled (if the system works as a server):

  • alsa and alsa-utils – sound subsystems;
  • atd – scheduler, not needed if there is a cron;
  • bluez-utiles – Bluetooth service;
  • cupsys – printer management subsystem;
  • dns-clean – DNS cleaning service when using dial-up;
  • fetchmail – email delivery service;
  • gdm – desktop manager (GUI);
  • gdomap – GNUstep support service;
  • hibernate – hibernation service;
  • hotkey-setup – hotkey support;
  • hotplug and hotplug-net – hot-plug devices;
  • ifrename – a network interface naming service;
  • laptop-mode – laptop mode, not needed on the server;
  • ppp and ppp-dns – services for connecting through a modem;
  • winbind, smbd, and nmbd are part of Samba and are needed for sharing with Windows devices.

The main recommendation – do not disable unknown processes, use the manual and Google.

The most important thing

Before starting optimization, you need to diagnose the system and identify weaknesses. Mindless tuning can only exacerbate the situation. Profiling will help to identify problem areas during the operation of the web server. Optimize your web server settings (Nginx and Apache), implement HTTP / 2.

Privacy Preference Center