I host four wordpress sites on a dedicated server from OVH. I found that my wordpress sites were taking a long time to load up. Sometimes, when I tried saving posts, they were erroring out. This sounded highly suspicious of memory issues on the server, so I decided to check.
I ran a free -m htop on the server, and found that most of the 4GB of RAM the server had had been used up by various processes, mainly spawns of mysqld (mysql daemon) which used around 1.6GB. The rest were used by clamav, bind service and others.
Mysql fixes:
Turning off performance schema.
Edit /etc/mysql/my.cnf:
Add under [mysqld]:
performance_schema = off
I didnt tamper with the rest of the settings. But on a restart of the mysql daemon, the memory usage went down to 580-760MB, something the server can live with.
Next I uninstalled the clamav package:
apt remove clamav
Next I stopped and disabled loading of bind, since its named process was taking another big chunk of memory. I did this by lazily using the virtualmin settings (Webmin>System>Bootup and Shutdown>bind9>Disable now and on boot)
After this, almost 800MB of memory became free, and system load came down to 0.16. Now, the main memory hoggers are mysqld (760MB), apache2 (400MB), php5(350MB), and rsyslogd(250MB). I could probably tune them if I read up on their finer settings. But for now, my server has started performing smoothly.
Joel G Mathew, known in tech circles by the pseudonym Droidzone, is an opensource and programming enthusiast.
He is a full stack developer, whose favorite languages are currently Python and Vue.js. He is also fluent in Javascript, Flutter/Dart, Perl, PHP, SQL, C and bash shell scripting. He loves Linux, and can often be found tinkering with linux kernel code, and source code for GNU applications. He used to be an active developer on XDA forums, and his tinkered ROMS used to be very popular in the early 2000s.
His favorite pastime is grappling with GNU compilers, discovering newer Linux secrets, writing scripts, hacking roms, and programs (nothing illegal), reading, blogging. and testing out the latest gadgets.
When away from the tech world, Dr Joel G. Mathew is a practising ENT Surgeon, busy with surgeries and clinical practise.