High RAM usage

High RAM usage

by Kyle Brown -
Number of replies: 11
My moodle site seems to be using a lot of RAM for low activity. We don't have many students that sign in at a time but after a while the server really eats away at the RAM. The server has 2 GB of RAM and it is currently using 1.5 GB of RAM. I am running in runlevel 3 (shell prompt) so no GUI. One of my teachers that knows linux things that it shouldn't be using 1.5 GB of RAM for what we do. A high school class size is normal ho many people will sign in at once (about 20 students are most). Here is my http.conf, php.ini, and my.cnf:

http.conf:

<IfModule prefork.c>
StartServers 8
MinSpareServers 5
MaxSpareServers 20
MaxClients 200
MaxRequestsPerChild 20
</IfModule>

# worker MPM
# StartServers: initial number of server processes to start
# MaxClients: maximum number of simultaneous client connections
# MinSpareThreads: minimum number of worker threads which are kept spare
# MaxSpareThreads: maximum number of worker threads which are kept spare
# ThreadsPerChild: constant number of worker threads in each server process
# MaxRequestsPerChild: maximum number of requests a server process serves
<IfModule worker.c>
StartServers 2
MaxClients 150
MinSpareThreads 25
MaxSpareThreads 75
ThreadsPerChild 25
MaxRequestsPerChild 0
</IfModule>

KeepAliveTimeout 15

MaxKeepAliveRequests 100

KeepAlive on

TimeOut 60

php.ini:

max_execution_time = 180 ; Maximum execution time of each script, in seconds
max_input_time = 180 ; Maximum amount of time each script may spend parsing request data
memory_limit = 40M ; Maximum amount of memory a script may consume
(8MB)

my.cnf:

[mysqld]
set-variable=max_connections=250
set-variable=max_connect_errors=150
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock

and location to files.

The server is a Dual P III 500 Mhz Proliant with 2 GB of RAM, 4 SCSI hard drivers (10,000 RPMs I think) in RAID 5 with spare, running Fedora Core 4. No php accelerator.

I have read though some of the other post but it didn't seem like the problem was fixed.
Average of ratings: -
In reply to Kyle Brown

Re: High RAM usage

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
A couple of things...

Can you work out which processes are using the memory using ps or top (run top and switch to sort by %MEM using the O key) or something (not the easiest thing to do unfortunately but hopefully the culprit will jump out). Is there a particular reason why you increased the mysql connections to 250. If you get that many, somethings wrong!
In reply to Howard Miller

Re: High RAM usage

by Maik Riecken -
"One of my teachers that knows linux things that it shouldn't be using 1.5 GB of RAM for what we do"

Then he doesn't know that much about linux. RAM management of linux differs from windows: You'll see that even if you install 8GB RAM that all memory will be occupied after a while.
Free RAM is wasted RAM. Most of of allocated RAM are disk cache or application buffers as you can see by the output of "free" at command line.

regards,

Maik
In reply to Maik Riecken

Re: High RAM usage

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
A very good point..... I assumed (but now I read again it wasn't stated) that the site was slow or grinding to a halt. If it is work fine then don't worry.
In reply to Maik Riecken

Re: High RAM usage

by Kyle Brown -
"Then he doesn't know that much about linux."

I take great offense to that.
In reply to Kyle Brown

Re: High RAM usage

by Maik Riecken -
Sorry for this. I just took a dictionary to look how the word "that" sounds in the ears of english speaking people - I haven't thought enough about this sentence and had no right to say it that strong and that general.

Anyway:
Your screenshots shows that everything is fine with your RAM-usage. It would be worthful to get another screen when the server is on high load.

regards,

Maik
In reply to Howard Miller

Re: High RAM usage

by Kyle Brown -
"why you increased the mysql connections to 250"

It was increased to try and solve a problem. When a high school class room size connected to the site, only about half were able to get on, the other half got a database connect error (saying the database might be over loaded). I think I might have picked that up from some place in the forum or from a message from another moodler. That was before we figure out that it was using up all of my RAM and using SWAP at the time.

Attached is a picture of top sorted by %MEM.
Attachment top2-14-08.PNG
In reply to Kyle Brown

Re: High RAM usage

by Iñaki Arenaza -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
So the machine isn't swapping at all (great!) and it's using nearly 900 MB (from the 1300 MB of used RAM) for file and disk caching . So it's really only using 400 MB of RAM to run the applications.

I guess there were almost no users hitting the machine when you took the screenshot smile

Saludos. Iñaki.
In reply to Iñaki Arenaza

Re: High RAM usage

by Kyle Brown -
"I guess there were almost no users hitting the machine when you took the screenshot"

You are correct, there were no users on. Next times I have users get on I will take another screen shot.

"So the machine isn't swapping at all"

Correct, I think it was swapping before I added RAM. It was at 1 GB, then we went to 1.5 GB and still had problems, now that we have the GUI turned off (running in runlevel 3) and 2 GB of RAM it seems to be running fine with a class room size. But it is only a matter of time until it has to use swap (depending on how many students are on and what they are doing).

" Have you got loads of optional stuff enabled in Apache? It's a good idea to disable all the modules you don't need."

I will have to go thought and see what modules are on and what is off. Can you supply me with a list of ones that need to be in the config?

Maik:

Apology accepted.
In reply to Kyle Brown

Re: High RAM usage

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Those apache processes are using more memory than I would expect. My experience has been about half what you are showing.

Have you got loads of optional stuff enabled in Apache? It's a good idea to disable all the modules you don't need.
In reply to Kyle Brown

Re: High RAM usage

by Myles Carrick -
Yes... the advice here is good. Simply hitting
top 

should report close to full usage of available memory. Try
free -m 

to see memory usage in MB... in particular to make sure the system isn't swapping (i.e. running out of memory and using disks instead)...

That said... there are some worrying signs in those config files. Have a look at http://docs.moodle.org/en/Performance to look at great ways to optimise your config. MaxClients of 200, for instance, is going to make it rather ugly if you do have periods of higher load (and when you've only 2GB of RAM and are sharing that with MySQL).

Do let us know how you get on.

MC