I am trying to figure out a situation where PHP is not consuming a lot of memory but instead causes a very high Committed_AS
result.
Take this munin memory report for example:
我一开始排队(10~30名工人),坚定的记忆就铺天盖地.我们在这个vps实例上有2G mem+2G交换,到目前为止,大约有6亿未使用的内存(约30%可用).
If I understand Committed_AS
correctly, it's meant to be a 99.9% guarantee no out of memory
issue given current workload, and it seems to suggest we need to triple our vps memory just to be safe.
I tried to reduce the number of queues from 30 to around 10, but as you can see the green line is quite high.
As for the setup: Laravel 4.1 with PHP 5.5 opcache enabled. The upstart script we use spawn instance like following:
instance $N
exec start-stop-daemon --start --make-pidfile --pidfile /var/run/laravel_queue.$N.pid --chuid $USER --chdir $HOME --exec /usr/bin/php artisan queue:listen -- --queue=$N --timeout=60 --delay=120 --sleep=30 --memory=32 --tries=3 >> /var/log/laravel_queue.$N.log 2>&1
I have seen a lot of cases when high swap use imply insufficient memory, but our swap usage is low, so I am not sure what troubleshooting step is appropriate here.
PS:在Laravel 4.1和我们的vps升级之前,我们没有这个问题,下面的图片可以证明这一点.
Maybe I should rephrase my question as: how are Committed_AS calculated exactly and how does PHP factor into it?
Updated 2014.1.29:
I had a theory on this problem: since laravel queue worker actually use PHP sleep()
when waiting for new job from queue (in my case beanstalkd
), it would suggest the high Committed_AS
estimation is due to the relatively low workload and relatively high memory consumption.
This make sense as I see Committed_AS
~= avg. memory usage / avg. workload
. As PHP sleep()
properly, little to no CPU are used; yet whatever memory it consumes is still reserved. Which result in server thinking: hey, you use so much memory (on average) even when load is minimal (on average), you should be better prepared for higher load (but in this case, higher load doesn't result in higher memory footprint)
If anyone would like to test this theory, I will be happy to award the bounty to them.