We've got a rather decent box for our Moodle site, but we are getting emalloc error crashes a lot. My current thought (they change a lot the more I read!) is that it's to do with APC/Zend, but as I'm still learning about Apache and MySQL, oh and PHP....and PHP accellerators, I thought it could be that I'm accidentally assigning too much memory, and when a whole class log on it's crashing it.
The box is a Quad 1.6GHz, 8GB RAM, 15K rpm discs in a Raid 10, running W2K3 SP2, Apache 2.2.2, PHP 5.1.4 and Moodle 1.9.3. APC is installed, but disabled to eliminate it as a cause. This started off as an XAMPPLITE package, but has been tinkered with.
So without further rambling, here are the highlights of my settings files, the full files are attached. I welcome being called an idiot if it means I can get to the bottom of this problem!!
Thanks in advance
max_execution_time = 60
memory_limit = 56M
;eaccelerator.shm_size = "0"
;eaccelerator.cache_dir = "C:\xampplite\tmp"
;eaccelerator.enable = "1"
;eaccelerator.optimizer = "0"
;eaccelerator.debug = "0"
;eaccelerator.check_mtime = "1"
;eaccelerator.filter = ""
;eaccelerator.shm_max = "0"
;eaccelerator.shm_ttl = "0"
;eaccelerator.shm_prune_period = "0"
;eaccelerator.shm_only = "0"
;eaccelerator.compress = "1"
;eaccelerator.compress_level = "9"
;eaccelerator.keys = "shm_and_disk"
;eaccelerator.sessions = "shm_and_disk"
;eaccelerator.content = "shm_and_disk"
;zend_extension_ts = "C:\xampplite\php\zendOptimizer\lib\ZendExtensionManager.dll"
;zend_extension_manager.optimizer_ts = "C:\xampplite\php\zendOptimizer\lib\Optimizer"
;zend_optimizer.enable_loader = 0
apc.enabled = 0
apc.shm_segments = 1
apc.shm_size = 512
apc.optimization = 0
apc.num_files_hint = 1000
apc.ttl = 0
apc.gc_ttl = 3600
apc.cache_by_default = On
apc.slam_defense = 0
apc.file_update_protection = 2
apc.enable_cli = 0
apc.stat = 1
net_buffer_length = 2K
thread_stack = 64K
key_buffer = 250M
max_allowed_packet = 1M
table_cache = 200
sort_buffer_size = 2M
read_buffer_size = 1M
read_rnd_buffer_size = 4M
open_files_limit = 8192
max_connections = 200
thread_concurrency = 4
query_cache_type = 1
query_cache_limit = 2M
query_cache_size = 150M
What it doesn't tell you is how to calculate MaxClients if you're running PHP. His calculation of Total RAM / 5MB would probably be safe for statically served pages, but I've seen Apache/PHP processes that use upwards of 100MB of RAM. Typically they are between 20MB and 30MB. Although, on some of my 64-bit installs of Apache/PHP I've seen them average 50-70MB.
A reliable way to set that would be to first run:
ps -ylC httpd --sort:rss
Take the total physical memory you want Apache to use and divide it by the highest value in the RSS column.
I knock that number down a bit to leave some room for a process that may come along and need more memory, and that's your MaxClients.
And here are some scripts for checking your MySQL config:
Thank you so much Thomas. I've been going through the Apache article and learning a fair bit. As I go I'm trying to build a calculation to work out a good set of values. I'm surprised there isn't a web-page to do this somewhere already. Or maybe the pro-tuners keep that for themselves!
Unfortunately our install is a WAMP setup, so a lot of the *nix commands and programs won't work, but it's giving me clues to work with.
At some point yesterday I did wonder if my PHP memory limits are too low, as the problems seem to hit when a whole class logs on, a lot of students take a quiz, the cron runs and gathers stats, or I (as an admin) log on. All these things have got me wondering if the common factor is the number of queries being run at those times are quite high or quite large. The problem is I don't know how to check that!
If I'm understanding this right, the amount of memory allocated to Apache is equal to the MaxKeepAliveRequests times by MaxClients, times by the PHP memory_limit, e.g.,
ApacheRAM = (apache.MaxKeepAlive x apache.MaxClients/ThreadsPerChild) x php.memory_limit
Is that really right? If so I need to change something because I'm assigning it 43Gb RAM! That makes me think my calculation is wrong, or maybe it explains exactly why I've been having trouble!!
I'm not very familiar with Windows, so I probably can't be more help. Sorry
In the end we solved this by installing the latest version on XAMPP*, so new Apache, MySQL, PHP and Moodle versions.
I can't say if this alone fixed it, or whether it was this and the tweaks I made to the config files.
* Yeah, yeah, yeah, I know what people say about not using XAMPP in production, but as far as I can see, this is refering to the out of the box version, not the one available here, which we're told has many security holes plugged. Add to that the tweaking I've done, and I'd think it's ok. Am I wrong?