Report this

What is the reason for this report?

MariaDB - How do I reduce RAM usage (Hosting WordPress Websites)

Posted on July 27, 2020

Hi,

We recently setup droplet with cPanel & WHM, on CentOS (Upgraded to CloudLinux) and installed MariaDB, Redis, LiteSpeed Cache, Imunify360, Railgun and a few other things.

We only host WordPress websites and most of them have WP Cron disabled, I don’t understand why they are using so much memory…

If I look in mysqladmin status it shows:

Uptime: 577820 Threads: 22 Questions: 2372265 Slow queries: 0 Opens: 11109 Flush tables: 1 Open tables: 2000 Queries per second avg: 4.105

If I look in mysqladmin processlist it shows:

| Id     | User        | Host      | db                 | Command | Time | State                    | Info             | Progress |
+--------+-------------+-----------+--------------------+---------+------+--------------------------+------------------+----------+
| 1      | system user |           |                    | Daemon  |      | InnoDB purge worker      |                  | 0.000    |
| 2      | system user |           |                    | Daemon  |      | InnoDB purge coordinator |                  | 0.000    |
| 3      | system user |           |                    | Daemon  |      | InnoDB purge worker      |                  | 0.000    |
| 4      | system user |           |                    | Daemon  |      | InnoDB purge worker      |                  | 0.000    |
| 5      | system user |           |                    | Daemon  |      | InnoDB shutdown handler  |                  | 0.000    |
| 9      | root        | localhost | information_schema | Sleep   | 15   |                          |                  | 0.000    |
| 139018 | root        | localhost |                    | Query   | 0    | Init                     | show processlist | 0.000    |
+--------+-------------+-----------+--------------------+---------+------+--------------------------+------------------+----------+

We have 1GB of swap & 2GB of RAM at the moment. If I check htop and sort by memory first you see the following:

https://i.imgur.com/pjAzVX3.png

We already disabled XML-RPC so it shouldn’t be that.

My my.cfg file located in /etc/my.cnf looks like:

[mysqld]
performance-schema = 0
datadir = /var/lib/mysql
socket = /var/lib/mysql/mysql.sock
symbolic-links = 0
log-error = /var/log/mysqld.log
innodb_file_per_table = 1
max_allowed_packet = 268435456
open_files_limit = 40000
innodb_buffer_pool_size = 54525952


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

To get a further reduction in memory usage you can convert ALL of your tables to MyISAM and then turn off innodb support in mysql altogether. This reduced my memory usage by 50%. and then restarting mysql.

Hi @ryanClam,

Having all of these instances does not mean a lot of RAM is being taken. Having said that, you can try and run a script called mysql_tunner. This is the GitHub page - https://github.com/major/MySQLTuner-perl

MySQLTuner is a script written in Perl that allows you to review a MySQL installation quickly and make adjustments to increase performance and stability. The current configuration variables and status data is retrieved and presented in a brief format along with some basic performance suggestions.

Additionally, please type in

free -mh

And see how much RAM is being taken. Please note, that RAM can be cached as well.

Regards, KFSys

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.