Best Memory Settings

Best Memory Settings

by Mohammad Yaseen -
Number of replies: 7

Hi

Having Moodle installed on a Ubuntu server with 16GB of memory, what are the best memory settings/configurations for PHP, MySQL, and Apache?

I don't have a thorough understanding of settings such as; PHP's memory_limit , Apache's MaxRequestWorkers, or MySQL's query_cache_size. Can someone, please, suggest approximate values for those settings? a brief description of those options will be greatly appreciated, if possible. And are there any other settings that could enhance the performance of Moodle even better? considering the 16GB memory.

Note 1: We have currently set our PHP's memory_limit to 1024MB. 

Note 2: Around 500 concurrent users might be accessing our Moodle at certain times.


Thank you

Average of ratings: -
In reply to Mohammad Yaseen

Re: Best Memory Settings

by Alex Rowe -
There are a lot of other similar questions to look through if you do a search.

For each of the settings you have listed there is very good documentation on the PHP/Apache/MySQL documentation site along with lots of good guides to help tune them.

On a separate note, PHP memory_limit won't have any major impact on performance and may cause issues being at 1024MB. You need to look into PHP prefork or PHP-FPM with Apache and configure it to have a max amount of workers/servers. MySQL query cache should also be disabled as it's deprecated and can cause worse performance.

If you're using a single server you also have to be careful that you don't commit too much memory to one application as your server would need to be able to handle the OS, MySQL, Apache, PHP etc all within the 16GB. e.g. RAM you give to MySQL then can't be used by PHP.
Average of ratings: Useful (1)
In reply to Alex Rowe

Re: Best Memory Settings

by Mohammad Yaseen -
Thank you, Alex
Appreciate your reply.

Regarding the MySQL Query Cache, it's recommended on the Moodle Performance recommendations page that the query cache should be set to 1.

and the attached picture. 

Do you think these recommendations on this page are accurate? 

check this page: https://docs.moodle.org/35/en/Performance_recommendations#MySQL_performance

Thanks
Attachment 2020-12-02 16_38_25-Window.png
In reply to Mohammad Yaseen

Re: Best Memory Settings

by Alex Rowe -
The recommendations on that page are quite out of date.

See: https://dev.mysql.com/doc/refman/5.7/en/server-system-variables.html#sysvar_query_cache_size

-> Note: The query cache is deprecated as of MySQL 5.7.20, and is removed in MySQL 8.0. Deprecation includes query_cache_size.

Current release is 5.7.32 (for the 5.7 branch) so it was deprecated in 2017.
In reply to Alex Rowe

Re: Best Memory Settings

by Visvanath Ratnaweera -
Picture of Particularly helpful Moodlers Picture of Translators
Hi Alex

Do you know the developments in MariaDB on this topic?
In reply to Visvanath Ratnaweera

Re: Best Memory Settings

by Alex Rowe -
Before version 10.1.7 it looks to be default enabled but with a size of 0 which effectively disables it. From 10.1.7 onwards it's disabled by default.

There was also an issue with MySQL where it could be disabled but have a size value which would still mean it's enabled (but not working) in MySQL causing connections to still flow through it.

Best commands are to set type=0 and size=0 which forces it off.

The query cache sounds like a good idea, but each query has to flow through the cache. It also stored the queries as case sensitive values and it must match exactly (spaces too). When a insert/update/delete type query comes in, MySQL must invalidate the cache for that table which is slow and during that time it can't process the new queries coming in.

A much better set up is to have whole DB in RAM with a properly set InnoDB buffer pool, properly configured log sizes (plus other InnoDB/MySQL settings) and have the DB files sitting on a fast disk, preferably SSD.
Average of ratings: Useful (1)
In reply to Mohammad Yaseen

Re: Best Memory Settings

by Ken Task -
Picture of Particularly helpful Moodlers

While you are getting good advice by Alex, suggest researching own server using tools which will help.

https://www.techrepublic.com/article/how-to-tune-apache-in-seconds-with-apache2buddy-pl/
https://raw.githubusercontent.com/will-parsons/apachebuddy.pl/master/apachebuddy.pl

https://www.linode.com/docs/guides/how-to-optimize-mysql-performance-using-mysqltuner/
https://raw.githubusercontent.com/major/MySQLTuner-perl/master/mysqltuner.pl

As Alex has said ... in a way ... usage will require tweaks ... upgrades to moodle will/might require tweaks ... the above tools will let you see stuff from your own server.

'SoS', Ken


Average of ratings: Useful (2)