0

I've migrated my websites to new servers with Ubuntu 16.04 LTS and larger RAM size. Everything seems to be working, but I faced with RAM / swap usage issue.

On my old Ubuntu 15.10 server I had 512 Mb of RAM and now I have 1 Gb of RAM memory. I hoped that after the migration performance will be better because of larger memory.

However I think that something is wrong with server configuration. All memory goes into swap. All my apps (MySQL, Nginx, PHP 7, etc) takes around 300-400 MB (30-40 %), but my swap is used by 100%.

Here is metics from top:

KiB Mem: 1012720 total, 14172 free, 302536 used, 696012 buff/cache 
KiB Swap: 262140 total, 0 free, 262140 used. 
629520 avail Mem

node:~$ free -m
              total        used        free      shared  buff/cache   available
Mem:            988         292         135          38         561         617
Swap:           255         255           0

Here is Munin memory metrics: Memory usage

I know about vm.swappiness parameter and it is equal for 20 in my case.

node:~$ cat /proc/sys/vm/swappiness 
20

Here is my full /etc/sysctl.conf:

kernel.panic=10
vm.panic_on_oom=1
vm.swappiness=20
vm.dirty_background_ratio=5
vm.dirty_ratio=10
net.ipv4.conf.all.accept_redirects=0
net.ipv6.conf.all.accept_redirects=0
net.ipv4.conf.default.accept_redirects=0
net.ipv6.conf.default.accept_redirects=0
net.ipv4.conf.all.secure_redirects=0
net.ipv4.conf.default.secure_redirects=0
net.ipv4.icmp_echo_ignore_broadcasts=1
net.ipv4.icmp_ignore_bogus_error_responses=1
net.ipv4.conf.all.forwarding=0
net.ipv6.conf.all.forwarding=0
net.ipv4.conf.default.forwarding=0
net.ipv6.conf.default.forwarding=0
net.ipv4.ip_forward=0
net.ipv4.conf.all.send_redirects=0
net.ipv4.conf.default.send_redirects=0
net.ipv4.conf.all.accept_source_route=0
net.ipv6.conf.all.accept_source_route=0
net.ipv4.conf.default.accept_source_route=0
net.ipv6.conf.default.accept_source_route=0
net.ipv4.conf.all.rp_filter=1
net.ipv4.conf.default.rp_filter=1
net.ipv4.conf.all.proxy_arp=0
net.ipv4.ip_local_port_range=1024 65535
net.core.somaxconn=65536
net.core.netdev_max_backlog=30000
fs.file-max=2097152
net.ipv4.tcp_tw_reuse=1
net.ipv4.tcp_tw_recycle=0
net.ipv4.tcp_fin_timeout=15
net.ipv4.tcp_max_tw_buckets=1440000
net.ipv4.tcp_window_scaling=1
net.ipv4.tcp_timestamps=1
net.ipv4.tcp_sack=1
net.ipv4.tcp_rfc1337=1
net.ipv4.tcp_no_metrics_save=1
net.ipv4.tcp_mem=50576 64768 98152
net.ipv4.tcp_rmem=4096 524288 11960320
net.core.rmem_max=11960320
net.ipv4.tcp_wmem=4096 524288 11960320
net.core.wmem_max=11960320
net.core.optmem_max=65535
net.ipv4.tcp_max_orphans=65535
net.ipv4.tcp_orphan_retries=0
net.ipv4.tcp_keepalive_time=1800
net.ipv4.tcp_keepalive_intvl=25
net.ipv4.tcp_keepalive_probes=5
net.ipv4.tcp_syncookies=1
net.ipv4.tcp_syn_retries=2
net.ipv4.tcp_synack_retries=3
net.ipv4.tcp_max_syn_backlog=3240000

Please help me to fix this problem.

Thanks

  • I believe you'll find the answer here: http://askubuntu.com/questions/103915/how-do-i-configure-swappiness – RPBCACUEAIIBH Mar 18 '17 at 10:53
  • It is a good answer, but it does not help. I've set vm.swappiness = 10, but swap is still using by system. I've 40-50% free RAM, but swap memory is also used. However according to vm.swappiness definites that swap will be used when 90% of RAM will be used in my case. So it does not work as expected. – mobidev911 Mar 20 '17 at 07:21

0 Answers0