How to limit CPU usage on server?
Number of replies: 9So I'm wondering, is there any way we can change settings on Moodle to limit some of the variables that affect the CPU usage. Here's what I heard back from my host as being the main factors:
- the size of the database
- what kind of query are being executed.
- and finally the number of simultaneous queries.
Perusing past postings, I noticed comments about changing "max clients," "connect_timeout," and the default for "dbpersist" in the config.php file. How might I alter any of these to ensure I don't cause problems again with my host, yet without affecting the normal operation of Moodle adversely?
Thanks in advance and please pardon my ignorance.
Best,
Steven
Re: How to limit CPU usage on server?
General strategies involve disabling features like some modules, all filters, html editor, etc (see Admin page). You can also make your cron job more spaced out (eg hourly).
However, if your Moodle usage is getting more serious and you WANT to use the features then it might be time to trade up to a provider that doesn't try to fit hundreds of sites on each server.
Re: How to limit CPU usage on server?
My Moodle usage is relatively light (really just an e-syllabus with some resource files uploaded), and my suspension was probably caused by a fluke (students hitting the site right after receiving an email announcing that lecture notes were posted for midterm review). But you're right, I should look into a more generous host, or host locally. After this term, I won't be teaching a 135 student class though either. The main thing is avoiding this from happening again. Next term I'll probably have no more than 70 students in 3 classes. Having to revert to WebCT as my backup while the site was down makes me appreciate Moodle and this wonderful community all the more.
Thanks again!
Best,
Steven
Re: How to limit CPU usage on server?
Thanks,
Ralph.
Re: How to limit CPU usage on server?
I have tried running moodle on a vserver and in my experience it is not a good deal because moodle , being such a feature-rich application can be an extreme resource hog...
Re: How to limit CPU usage on server?
"nice -n 15 command"
The value for 15 can be from -20 (highest priority) to 19 (lowest priority). You might try it with 15 and see if your host is ok with the load.
I'm assuming your running the command late at night. If so it's a bit strange that your host would object to it since that should not be a peak load time for them.
Re: How to limit CPU usage on server?
Most shared environments are not even going to allow you to modify the php.ini file. Even if you can see one and make changes, it is not going to take. Just what a shared server needs, ini files that users can make changes too....
Re-nice is not going to do a thing either, it only changes the priority of the cron, not the load factor. And again, odds are pretty darn slim that you can re-nice any process, another unlikely privilage, allowing users to re-prioritize services...
The host is looking at CPU usage logs and Moodle is a resource hog when it comes to the cron job.
The best chance you stand is to move it out to the 1 hour execution instead of the 5 or 10 minute setup. If you have a busy Moodle site, you may just as well own up to the fact that you are going to need a dedicated server
Re: How to limit CPU usage on server?
Re: How to limit CPU usage on server?
ORIGINAL MESSAGE FROM MY HOSTING
Hello,
The following script was disabled because it was causing issues to the server:
/home/campu14/public_html/course/view.php
/home/campu14/public_html/file.php
Here are the log details:
13850
DOCUMENT_ROOT=/home/campu14/public_html
GATEWAY_INTERFACE=CGI/1.1
HTTP_ACCEPT=*/*
HTTP_ACCEPT_ENCODING=gzip, deflate
HTTP_ACCEPT_LANGUAGE=es
HTTP_CONNECTION=Keep-Alive
HTTP_COOKIE=MoodleSession=17d1bded61cedc7de595cd91ab5f20f7; MoodleSessionTest=XJcm9WarnT; MOODLEID_=%25E9%25D9%251FB%25B0%257C%25A2%2502%25EFT%25E64%25E2Z%25DBe%25C7%25DFm%2527
HTTP_HOST=www.campus-virtual.es
HTTP_REFERER=http://www.campus-virtual.es/course/category.php?id=124
HTTP_USER_AGENT=Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50727; InfoPath.1)
PATH=/bin:/usr/bin
PHPRC=/home/campu14/public_html
QUERY_STRING=id=149
REDIRECT_STATUS=200
REMOTE_ADDR=193.146.93.1
REMOTE_PORT=44894
REQUEST_METHOD=GET
REQUEST_URI=/course/view.php?id=149
SCRIPT_FILENAME=/home/campu14/public_html/course/view.php
SCRIPT_NAME=/course/view.php
SERVER_ADDR=67.210.99.123
SERVER_ADMIN=webmaster@campus-virtual.es
SERVER_NAME=campus-virtual.es
SERVER_PORT=80
SERVER_PROTOCOL=HTTP/1.1
SERVER_SIGNATURE=<ADDRESS>Apache/1.3.39 Server at campus-virtual.es Port 80</ADDRESS>
SERVER_SOFTWARE=Apache/1.3.39 (Unix) mod_fastcgi/2.4.2 mod_bwlimited/1.4 mod_auth_passthrough/1.8 mod_log_bytes/1.2 FrontPage/5.0.2.2635 mod_ssl/2.8.30 OpenSSL/0.9.7a
UNIQUE_ID=R057r0PSYg8AAEElXDk
11353
DOCUMENT_ROOT=/home/campu14/public_html
GATEWAY_INTERFACE=CGI/1.1
HTTP_ACCEPT=*/*
HTTP_ACCEPT_ENCODING=gzip, deflate
HTTP_ACCEPT_LANGUAGE=es
HTTP_CONNECTION=Keep-Alive
HTTP_COOKIE=MoodleSession=33610d584eddb23b0817b23725b3e41f; MoodleSessionTest=oPA7Ov6ku9; MOODLEID_=%25E6%25C8%250BM%25A1y%25BF%2509%25F2F%25EF%2527%25E7%255D%25D6m%25CF
HTTP_HOST=www.campus-virtual.es
HTTP_REFERER=http://www.campus-virtual.es/course/view.php?id=149
HTTP_USER_AGENT=Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50727; InfoPath.1)
PATH=/bin:/usr/bin
PATH_INFO=/149/word/practicasyteoria/practicadiagrama.pdf
PATH_TRANSLATED=/home/campu14/public_html/file.php
PHPRC=/home/campu14/public_html
QUERY_STRING=
REDIRECT_STATUS=200
REMOTE_ADDR=193.146.93.1
REMOTE_PORT=30574
REQUEST_METHOD=GET
REQUEST_URI=/file.php/149/word/practicasyteoria/practicadiagrama.pdf
SCRIPT_FILENAME=/home/campu14/public_html/file.php
SCRIPT_NAME=/file.php
SERVER_ADDR=67.210.99.123
SERVER_ADMIN=webmaster@campus-virtual.es
SERVER_NAME=campus-virtual.es
SERVER_PORT=80
SERVER_PROTOCOL=HTTP/1.1
SERVER_SIGNATURE=<ADDRESS>Apache/1.3.39 Server at campus-virtual.es Port 80</ADDRESS>
SERVER_SOFTWARE=Apache/1.3.39 (Unix) mod_fastcgi/2.4.2 mod_bwlimited/1.4 mod_auth_passthrough/1.8 mod_log_bytes/1.2 FrontPage/5.0.2.2635 mod_ssl/2.8.30 OpenSSL/0.9.7a
UNIQUE_ID=R06BJUPSYg8AACXjd-c
Your resource usage is also high. Here are your resource usage details at this time:
User: ---
Domain: campus-virtual.es
CPU%: 17.39
MEM: 0.75
MySQL: 0.3
Top Process %CPU 77.0 /usr/local/php5/bin/php-cgi
Top Process %CPU 49.0 [php-cgi]
Top Process %CPU 31.0 /usr/local/php5/bin/php-cgi
Please upgrade all third party scripts to the latest version and remove any scripts that are no longer in use. Also, make any appropriate modifications to reduce your resource usage.
Please keep us updated on your progress.
Thank you for your cooperation
--
Do not hesitate to contact us if you have any questions
Re: How to limit CPU usage on server?
http://moodle.org/mod/forum/discuss.php?d=85584