How to maximize memory usage

How to maximize memory usage

Kompli Tivi發表於
Number of replies: 10

I have a 8 core, 32gb dedicated moodle server.

Moodle never utilize more than 8gb of the memory, even in high load (400 users). Idled at 7GB, so the load only adds 1 more gb.
Resulting random disconnection and very slow performance in some users.

I use apache with php-fpm.

this setting reduce the problem, but i'm not sure.

KeepAlive Off
<IfModule prefork.c>
   StartServers        5
   MinSpareServers     5
   MaxSpareServers     10
   MaxClients          512
   MaxRequestsPerChild 3000
   ServerLimit 512
</IfModule>

the problem lessened after i restart apache though.
after some time, a number of students started to experience slowness.

In moodle i selected 4096mb in "Extra PHP memory limit", no options higher.

評比平均分數: -
In reply to Kompli Tivi

Re: How to maximize memory usage

Chris Fryer發表於

Hi Stephen

If you're using the "prefork" MPM, then you aren't using PHP-FPM at all. You will be using PHP as an Apache module, and this will not be efficient. You should instead use either the "worker" or "event" Apache MPM.

Chris

In reply to Chris Fryer

Re: How to maximize memory usage

Kompli Tivi發表於

I weren't using MPM, i added it in panic mode.
I read it somewhere and it suggest me to add MaxClients the configurations that were missing in httpd.conf.
Don't know if its working or not, but as soon as i restart php the problem disappear.

This is my php-fpm config:

[15043048411520]
user = admin
group = admin
listen = 8001
pm = dynamic
pm.max_children = 9999
pm.start_servers = 1
pm.min_spare_servers = 1
pm.max_spare_servers = 5
php_admin_value[upload_tmp_dir] = /home/www/tmp
php_admin_value[session.save_path] = /home/www/tmp
php_value[max_execution_time] = 2400
php_value[memory_limit] = 512M
php_value[session.save_path] = /home/www/tmp

I upped the memory_limit from 128M.

With 400 users online (not concurrent) should i expect my memory to fill up?
Or this is normal?

Activity : Quiz with 50 questions, each question with one audio files. 30 minutes per test.

In reply to Kompli Tivi

Re: How to maximize memory usage

Mathew Gancarz發表於
Core developers的相片

Have you looked at or can you monitor the network bandwidth/response time? Are the audio files hosted by moodle or somewhere else? If you are saturating the network connection of the moodle server by trying to serve up hundreds of audio files at one time, it has nothing to do with PHP.

You can use something like jmeter to simulate load. See https://docs.moodle.org/34/en/JMeter_test_plan_generator or take a look at https://moodle.org/mod/forum/discuss.php?d=358724

In reply to Mathew Gancarz

Re: How to maximize memory usage

Kompli Tivi發表於

the sound files are 100kb at most, so if 1 connection is 1000kbps it only takes 400mbps for 400 user download at the same time, which is certaintly never the case.
I have dual gigabit nic with 60MB/s or 480mbps real bandwidth.

So network saturation is not the problem.

I think this problem could be the maxclient config.
The problem occurs only with 20% of students, the server rejects them.

Most students that are succesfully served don't experience slowness.

I cannot use JMeter right now as the server still live.

In reply to Kompli Tivi

Re: How to maximize memory usage

Howard Miller發表於
Core developers的相片 Documentation writers的相片 Particularly helpful Moodlers的相片 Peer reviewers的相片 Plugin developers的相片

Is the database on the same server?

In reply to Howard Miller

Re: How to maximize memory usage

Kompli Tivi發表於

Yes the database is on the same server.

I use samsung 960 enterprise ssd, very high IO.
With 8 core never reached 15%.
So i don't think the hardware is the bottleneck.

In reply to Kompli Tivi

Re: How to maximize memory usage

Howard Miller發表於
Core developers的相片 Documentation writers的相片 Particularly helpful Moodlers的相片 Peer reviewers的相片 Plugin developers的相片

You anticipated the wrong question 眨眼

I was jus wondering how you'd tuned the database (if you have) to share the available memory between the database and the web server (and everything else)? Most default database installations are very conservative in resource usage. You can make a massive difference to the DB performance by allocating a chunk of memory and doing some tuning. 

In reply to Howard Miller

Re: How to maximize memory usage

Kompli Tivi發表於

Hi, i used mysqltuner and did everything that it suggested.

Does this have anything to do with user / memory capping?

In reply to Kompli Tivi

Re: How to maximize memory usage

Ken Task發表於
Particularly helpful Moodlers的相片

"400 user download at the same time, which is certaintly never the case
The problem occurs only with 20% of students, the server rejects them.
"

How are you able to determine (20%) X students attempt to play an mp3 the server rejects?

'Server rejects' meaning the operating system or web service rejects, or Moodle reports an error or times out?

In the mysqltuner output did it show any info about these:

Highest usage of available connections
Aborted connections

If you adjusted settings just what did you adjust?

"user / memory capping" describe what you mean here.
Are we thinking that Moodle restricts a user?
Or are we asking about where you host ... which suggest a memory cap.

With the quiz ... are you displaying all 50? questions with one click?  Not sure if Moodle starts to push the .mp3 to clients or not but that could be a factor.

'spirit of sharing', Ken