FreeBSD 上跑 Apache 2.2 worker 的方法在「apache22 (worker) + mod_fastcgi + php5-fcgi」這篇寫過了,同樣的架構在 Debian 上跑卻發現比 prefork 還吃記憶體,花了一些時間找,發現是預設的 Stack 太大造成的,所以:
<IfModule mpm_worker_module>
ThreadStackSize 65536
ThreadLimit 256
StartServers 1
MaxClients 256
MinSpareThreads 1
MaxSpareThreads 256
ThreadsPerChild 256
MaxRequestsPerChild 0
</IfModule>加了 ThreadStackSize 這個設定後,每個 thread 的 stack 就會比較小了 (預設超過 1MB,不記得多少了),這個方式跑了一個月後還蠻正常的。
