Tuesday, February 18, 2014

Apache Memory管理:Prefork and Worker

這幾日觀察提供數種服務的Linode server上,各個process使用資源的情況,發現一個apache的child process約需要20MB的memory,若是沒有多加管控,容易超出linux的memory上限,觸發OOM,部分process會被作業系統kill。

"It is not unheard of for even small to moderate sized Python web applications to consume 30MB or more of private memory in each child server process." -- from this reference

同時發現apache在分process與task有兩個mode,其一為prefork、其二為worker:
  • prefork:一個request(task)由其中一個apache process負責
  • worker:一個request(task)由多個apache process負擔
於是我開始思考使用哪個mode適合我的用途,而發現他人的建議下,除非是跑PHP的情況,使用worker模式並無太大幫助,而apache預設是prefork。

"If you use mod_wsgi daemon mode, it doesn't matter which Apache MPM you use, although suggested that for UNIX systems worker MPM be used unless you are stuck with having to also host PHP applications using mod_php as some PHP extensions aren't thread safe." -- from this reference

No comments:

Post a Comment