PHP CLI&分叉儿童 [英] PHP CLI & Forking children

查看:48
本文介绍了PHP CLI&分叉儿童的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是多进程编程的新手,是否应该避免向父母的孩子分钱?$ / b

我想要从父母和每个孩子中产生10个孩子

孩子产生另外5个孩子,这些孩子处理大量数据(200

行),大量使用CPU和regexp

解决方案

2007年9月29日星期六03:12:19 -0700, qw ******* @ googlemail.com 写道:


>我是新来的多进程编程,应该避免让父母的孩子分开吗?

我想从父母那里产生10个孩子,每个孩子都会产卵另外5个孩子处理大量数据(200行/行),大量使用CPU和正则表达式



所以你要产生500个进程?你有非常多的CPU来运行它们吗?否则只有少数几个会在任何时间运行,并且肯定会损失有用的吞吐量。


-

Andy Hassall :: an**@andyh.co.uk :: http://www.andyh.co.uk
http://www.andyhsoftware.co.uk/space ::磁盘和FTP使用情况分析工具


9月29日下午3:49,Andy Hassall< a ... @ andyh.co.ukwrote:


那你要产生500个流程吗?你有非常多的CPU来运行它们吗?否则只有少数实际上会在任何时间运行,并且肯定会损失有用的吞吐量。



也许我给出的例子很糟糕:) PHP脚本如何启动

4个孩子,每个孩子分叉另外5个孩子(20个流程)


这个开发难题或可能的额外错误?


qw * ******@googlemail.com 写道:


9月29日下午3:49,Andy Hassall< a ... @ andyh.co.ukwrote:


>那你要产生500个流程吗?你有非常多的CPU来运行它们吗?否则,实际上只有少数会在任何时候运行,并且肯定会失去有用的吞吐量。



也许这个例子我给了很糟糕:)发布PHP脚本怎么样

4个孩子,每个孩子分叉另外5个孩子(20个流程)


这个开发是否会让人头疼或者可能的额外错误?



只是想知道 - 为什么还需要fork进程?这样做有很多开销,如果他们都是CPU绑定的话,那么你不会得到任何东西(除非你有一大堆CPU')。


如果您使用不同的

资源进行不同的处理,分叉是很好的。但是当他们不得不争夺相同的资源时,

的表现往往会下降。


-

==== ==============

删除x来自我的电子邮件地址

Jerry Stuckle

JDS计算机培训公司
js ******* @ attglobal.net

==================


I''m new to multi-process programming, should one avoid forking
children from children of a parent?

I''d like to spawn 10 children from the parent and each of those
children spawns another 5 children which process chunks of data (200
rows) with heavy usage of CPU and regexp

解决方案

On Sat, 29 Sep 2007 03:12:19 -0700, qw*******@googlemail.com wrote:

>I''m new to multi-process programming, should one avoid forking
children from children of a parent?

I''d like to spawn 10 children from the parent and each of those
children spawns another 5 children which process chunks of data (200
rows) with heavy usage of CPU and regexp

So you''re spawning 500 processes? Do you have a very large number of CPUs to
run them on? Otherwise only a few will actually be running at any time, and
you''ll be losing useful throughput to overhead, surely.

--
Andy Hassall :: an**@andyh.co.uk :: http://www.andyh.co.uk
http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool


On Sep 29, 3:49 pm, Andy Hassall <a...@andyh.co.ukwrote:

So you''re spawning 500 processes? Do you have a very large number of CPUs to
run them on? Otherwise only a few will actually be running at any time, and
you''ll be losing useful throughput to overhead, surely.

Maybe the example I gave was bad :) How about PHP script with launches
4 children, with each child forking another 5 children (20 processes)

Would this development headaches or possible extra bugs?


qw*******@googlemail.com wrote:

On Sep 29, 3:49 pm, Andy Hassall <a...@andyh.co.ukwrote:

> So you''re spawning 500 processes? Do you have a very large number of CPUs to
run them on? Otherwise only a few will actually be running at any time, and
you''ll be losing useful throughput to overhead, surely.


Maybe the example I gave was bad :) How about PHP script with launches
4 children, with each child forking another 5 children (20 processes)

Would this development headaches or possible extra bugs?

Just wondering - why do you need to fork processes, anyway? There''s a
lot of overhead in doing it, and if they''re all CPU bound anyway you
aren''t going to gain anything (unless you have a potload of CPU''s).

Forking is good if you have different processes using different
resources. But when they have to contend for the same resource,
performance often goes down.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================


这篇关于PHP CLI&amp;分叉儿童的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆