drrc61668568 2012-10-20 08:01
浏览 24
已采纳

加快php-cli

Why is a php cli process using 25% of CPU, is there a way to reduce this? Right now I'm running 3 instances but obviously I would like to run much more to finish the job faster.

Background info: I'm moving data from a transbase db to mysql db.enter image description here EDIT: If I run this in a browser there isn't such a noticeable load on the CPU.

  • 写回答

1条回答 默认 最新

  • douquanqiao6788 2012-10-20 11:43
    关注

    More processes doesn't mean faster processing. The PHP process takes as much CPU as it can to finisgh the task as quick as possible. It's probably 25% because you got a quad-core processor and it's a single threaded task.

    Ideally, you would need 4 processes if you could assign each of them to a different code. Also, because of waiting for database or disk-I/O, a single thread cannot fully use all CPU power all the time, so go ahead and run more processes. It's not that a 5th processes will crash because all CPU power is used up; it will just take its share, while the OS divides processing power to all running processes.

    Just dont' start too many; every process has a little overhead, and you won't benefit from having 200 simultaneous processes.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?