I am running a vBuletin forum as a hobby and I was using a shared hosting service until a couple of days ago. Because the amount of visitors grew and the forum seemed to be slower and slower every day, I tought it is time to change to a cloud server with the following specs:

6 CPU vCore 300 GB SSD 12 GB RAM 1 GB Swap

After the change I made the experience, that the forum runs even slower now and that my free memory in PLESK is always extremly low. You can see the "free memory" within the last 24 hours below in the screenshot. The peaks with free memory are caused due to a sql restart.

Free Memory

When I check the free memory within the last hours in Plesk, I can see that the memory is running always very low:

Plesk Memory within the last hours

at the same time in the server overview, I can see that there is some more memory free:

Server Memory

So I realized that I need to do 1) something with my PHP and SQL configuration and/or 2) need to upgrade the server itself. Of course I hope that I can optmize with the settings since option 2 is more expensive :)

Unfortunately I have no idea how to successfully optimize my server for my forum, but I already read a lot here on stack.

When I run mysqltuner I get the following results:

 ***>>  MySQLTuner 1.7.19 - Major Hayden <major@mhtx.net>
 >>  Bug reports, feature requests, and downloads at http://mysqltuner.pl/
 >>  Run with '--help' for additional options and output filtering
[--] Skipped version check for MySQLTuner script
[--] Performing tests on
[OK] Currently running supported MySQL version 10.3.23-MariaDB-0+deb10u1
[OK] Operating on 64-bit architecture
-------- Log file Recommendations ------------------------------------------------------------------
[OK] Log file /var/log/mysql/error.log exists
[--] Log file: /var/log/mysql/error.log(1K)
[OK] Log file /var/log/mysql/error.log is readable.
[OK] Log file /var/log/mysql/error.log is not empty
[OK] Log file /var/log/mysql/error.log is smaller than 32 Mb
[!!] /var/log/mysql/error.log contains 8 warning(s).
[!!] /var/log/mysql/error.log contains 6 error(s).
[--] 0 start(s) detected in /var/log/mysql/error.log
[--] 0 shutdown(s) detected in /var/log/mysql/error.log
-------- Storage Engine Statistics -----------------------------------------------------------------
[--] Data in InnoDB tables: 12.6G (Tables: 511)
[--] Data in MyISAM tables: 25.4M (Tables: 15)
[OK] Total fragmented tables: 0
-------- Analysis Performance Metrics --------------------------------------------------------------
[--] innodb_stats_on_metadata: OFF
[OK] No stat updates during querying INFORMATION_SCHEMA.
-------- Security Recommendations ------------------------------------------------------------------
[OK] There are no anonymous accounts for any database users
[OK] All database users have passwords assigned
[--] There are 620 basic passwords in the list.
-------- CVE Security Recommendations --------------------------------------------------------------
-------- Performance Metrics -----------------------------------------------------------------------
[--] Up for: 15h 21m 49s (13M q [241.731 qps], 148K conn, TX: 296G, RX: 28G)
[--] Reads / Writes: 96% / 4%
[--] Binary logging is disabled
[--] Physical Memory     : 12.0G
[--] Max MySQL memory    : 16.1G
[--] Other process memory: 0B
[--] Total buffers: 6.3G global + 66.9M per thread (151 max threads)
[--] P_S Max memory usage: 0B
[--] Galera GCache Max memory usage: 0B
[OK] Maximum reached memory usage: 9.4G (78.48% of installed RAM)
[!!] Maximum possible memory usage: 16.1G (134.57% of installed RAM)
[!!] Overall possible memory usage with other process exceeded memory
[OK] Slow queries: 0% (774/13M)
[OK] Highest usage of available connections: 31% (48/151)
[OK] Aborted connections: 0.00%  (0/148403)
[!!] name resolution is active : a reverse name resolution is made for each new connection and can reduce performance
[OK] Query cache is disabled by default due to mutex contention on multiprocessor machines.
[OK] Sorts requiring temporary tables: 0% (167 temp sorts / 393K sorts)
[!!] Joins performed without indexes: 647
[!!] Temporary tables created on disk: 54% (128K on disk / 233K total)
[OK] Thread cache hit rate: 99% (48 created / 148K connections)
[OK] Table cache hit rate: 99% (1K open / 1K opened)
[!!] table_definition_cache(400) is lower than number of tables(685)
[OK] Open file limit used: 0% (153/16K)
[OK] Table locks acquired immediately: 100% (1M immediate / 1M locks)
-------- Performance schema ------------------------------------------------------------------------
[--] Performance schema is disabled.
[--] Memory used by P_S: 0B
[--] Sys schema isn't installed.
-------- ThreadPool Metrics ------------------------------------------------------------------------
[--] ThreadPool stat is enabled.
[--] Thread Pool Size: 6 thread(s).
[--] Using default value is good enough for your version (10.3.23-MariaDB-0+deb10u1)
-------- MyISAM Metrics ----------------------------------------------------------------------------
[!!] Key buffer used: 19.2% (25M used / 134M cache)
[OK] Key buffer size / total MyISAM indexes: 128.0M/9.0M
[OK] Read Key buffer hit rate: 100.0% (315M cached / 1K reads)
[OK] Write Key buffer hit rate: 100.0% (88 cached / 88 writes)
-------- InnoDB Metrics ----------------------------------------------------------------------------
[--] InnoDB is enabled.
[--] InnoDB Thread Concurrency: 0
[OK] InnoDB File per table is activated
[!!] InnoDB buffer pool / data size: 6.0G/12.6G
[!!] Ratio InnoDB log file size / InnoDB Buffer pool size (8.33333333333333 %): 256.0M * 2/6.0G should be equal to 25%
[!!] InnoDB buffer pool instances: 8
[--] Number of InnoDB Buffer Pool Chunk : 48 for 8 Buffer Pool Instance(s)
[OK] Innodb_buffer_pool_size aligned with Innodb_buffer_pool_chunk_size & Innodb_buffer_pool_instances
[OK] InnoDB Read buffer efficiency: 100.00% (41905422167 hits/ 41906965493 total)
[OK] InnoDB Write log efficiency: 99.06% (51908272 hits/ 52400204 total)
[OK] InnoDB log waits: 0.00% (0 waits / 491932 writes)
-------- AriaDB Metrics ----------------------------------------------------------------------------
[--] AriaDB is enabled.
[OK] Aria pagecache size / total Aria indexes: 128.0M/1B
[OK] Aria pagecache hit rate: 99.9% (132M cached / 125K reads)
-------- TokuDB Metrics ----------------------------------------------------------------------------
[--] TokuDB is disabled.
-------- XtraDB Metrics ----------------------------------------------------------------------------
[--] XtraDB is disabled.
-------- Galera Metrics ----------------------------------------------------------------------------
[--] Galera is disabled.
-------- Replication Metrics -----------------------------------------------------------------------
[--] Galera Synchronous replication: NO
[--] No replication slave(s) for this server.
[--] Binlog format: MIXED
[--] XA support enabled: ON
[--] Semi synchronous replication Master: OFF
[--] Semi synchronous replication Slave: OFF
[--] This is a standalone server
-------- Recommendations ---------------------------------------------------------------------------
General recommendations:
    Control warning line(s) into /var/log/mysql/error.log file
    Control error line(s) into /var/log/mysql/error.log file
    MySQL was started within the last 24 hours - recommendations may be inaccurate
    Reduce your overall MySQL memory footprint for system stability
    Dedicate this server to your database for highest performance.
    Configure your accounts with ip or subnets only, then update your configuration with skip-name-resolve=1
    We will suggest raising the 'join_buffer_size' until JOINs not using indexes are found.
             See https://dev.mysql.com/doc/internals/en/join-buffer-size.html
             (specially the conclusions at the bottom of the page).
    When making adjustments, make tmp_table_size/max_heap_table_size equal
    Reduce your SELECT DISTINCT queries which have no LIMIT clause
    Performance schema should be activated for better diagnostics
    Consider installing Sys schema from https://github.com/mysql/mysql-sys for MySQL
    Consider installing Sys schema from https://github.com/FromDual/mariadb-sys for MariaDB
    Before changing innodb_log_file_size and/or innodb_log_files_in_group read this: https://bit.ly/2TcGgtU
Variables to adjust:
  *** MySQL's maximum memory usage is dangerously high ***
  *** Add RAM before increasing MySQL buffer variables ***
    join_buffer_size (> 256.0K, or always use indexes with JOINs)
    tmp_table_size (> 16M)
    max_heap_table_size (> 16M)
    table_definition_cache(400) > 685 or -1 (autosizing if supported)
    performance_schema = ON enable PFS
    innodb_buffer_pool_size (>= 12.6G) if possible.
    innodb_log_file_size should be (=768M) if possible, so InnoDB total log files size equals to 25% of buffer pool size.

The content of the my.cnf looks like this (edited by myself, with understanding from reading here on stack:

bind-address = ::ffff:
innodb_lock_wait_timeout = 600
innodb_buffer_pool_size = 6G
innodb_log_file_size = 256M
innodb_flush_log_at_trx_commit = 2
innodb_stats_on_metadata = 0

The content of my php.ini is the following:

    memory_limit = 256M
max_execution_time = 1200
max_input_time = 600
post_max_sice = 64M
upload_max_filesize = 16M
opcache.enable = on

So I am looking desperately for help, tips, hints how I can optimize my server to earn some more performance for my website which is really, really slow :(

Have a nice day and greetings!

I got some more stats here, are they helpful?

enter image description here

enter image description here

enter image description here

enter image description here

  • You will need far more extensive and granular performance metrics to identify the root cause of your performance issues. Low free memory is not necessarily a problem, operating systems typically use all otherwise unused memory for caching. As a first step you need to establish what resource you are depleting, is it CPU or disk I/O. Then go from there. – Gordan Bobic Oct 20 '20 at 5:11
  • Thanks for the feedback! As far as I can see that, CPU and disk I/O are no problem. But the MySQL Memory usage runs and stays quite high above 7 GB and Plesk shows a "broken heart" in the overview. So I thought one of the major problems comes from mysql memory usage? – quattro123 Oct 20 '20 at 5:32
  • You are setting the buffer pool to 6GB, between that and all other memory usage of MySQL, 7GB seems reasonable. You can try reducing the buffer pool by 1GB and see if that makes a difference, but I suspect your performance issue lies elsewhere. – Gordan Bobic Oct 20 '20 at 8:48
  • So the performance should be better by setting the buffer to 5 or 7 GB? – quattro123 Oct 20 '20 at 9:34
  • Unless your problem is excessive swapping, reducing it to 5GB won't help with performance. It might make your memory warning go away. Increasing it to 7GB will probably result in mysqld getting killed due to an out of memory condition. – Gordan Bobic Oct 20 '20 at 9:47

You are running MariaDB, PHP, and the web server all on the same 8GB machine? If so, 6G for innodb_buffer_pool_size is too high. Lower it to 4G. See if the RAM usage stays lower than 8G. If so, you can raise it some -- but not so much that swapping occurs.

Hmmm... One thing says 8G, one says 12G. Regardless, lower the buffer_pool setting to avoid swapping.

The buffer_pool is important to performance. But it must be sacrificed to avoid swapping.

A better approach to performance is to use the slowlog to identify the 'worst' queries, then improve them. http://mysql.rjweb.org/doc.php/mysql_analysis#slow_queries_and_slowlog

  • Sorry, it IS 12 GB Ram, I wrote it wrong. Edited the first post. I changed the buffer size to 4 GB, but still, the "free ram" value runs down to 100-200 MB or less. – quattro123 Oct 22 '20 at 8:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.