How to optimize the php process memory usage?

后端 未结 2 657
生来不讨喜
生来不讨喜 2020-12-10 14:40

I am running a wordpress site and each PHP process usage about 200mb to 250mb resident size memory. With 16GB of ram, the server can only handle about 70 processes. By incre

2条回答
  •  猫巷女王i
    2020-12-10 15:04

    Rasmus Lerdorf did a conference about PHP performance at Confoo in 2010 and he used a Wordpress blog as an example, this should give you great tools to answer your question:

    http://talks.php.net/show/confoo10/1

    To sum up:

    • Run a phpinfo() and disable PHP extensions that you don't use. They can take a lot of memory (imagick, curl, ...)
    • Generate a graph of your includes using the inclued.so extension. You might load useless functions in your wordpress setup.
    • Run benchmarks with siege. Sometimes, tiny optimisations have great impact on performance, so make sure you have metrics, to help you make your decisions.
    • Use callgrind to show where you're loosing performance. In one of my project I was using md5() to hash my SQL queries and cache them. The md5() calls where using 20% of the CPU time.

    I would definitely start by disabling PHP extensions if possible.

提交回复
热议问题