perkiset

I am considering an app that needs to emulate multithreading from an

ajax

  call.

My first preference would be to have the app fire off a bunch of

Apache

  calls, which come back instantly yet continue working so that the calling

PHP

  script is not "serially waiting" for each one of the

Apache

  calls to be complete... but I am having a bit of trouble with flushing the buffer out consistently (more work and research to do here). If I can work it out, this is an important part of a scalability plan, so I'd really like to make this work.

But another way is to exec() it with a > /dev/null & suffix and let them run as daemons to get the jobs done... but I am concerned with the load I will place on my system to do this, because I'm firing up a new shell to run a new instance of the

PHP

  interpreter to run my script... they're not long, perhaps 2-3 seconds each and low processor because the majority of the wait is on the client that I am hitting.

I'm just wondering if I get hit with 100 surfers in a single moment and each one fires off 16 tasks what the real cost in terms of memory might look like.

Linux

 heads seem to be of the opinion that it's quite a hit to fire off another shell for each processing, but what is "quite a hit?" Isn't this exactly how

Apache

  fires things off in a CGI arrangement?

Thanks in advance,
-p


emonk

quote
Isn't this exactly how

Apache

  fires things off in a CGI arrangement?


Yeah, and that's part of the reason that you shouldn't run

PHP

  as a CGI, but instead use the

apache

  module. It reduces overhead significantly.

As for the rest, I don't really know. I'm trying to figure out something very similar myself right now, and I'm pretty stumped. I think I'm just gonna override the maximum execution time, and do a bunch of forking with the whole thing output buffered.

jammaster82

quote author=perkiset link=topic=772.msg5325#msg5325 date=1202925264


I'm just wondering if I get hit with 100 surfers in a single moment and each one fires off 16 tasks what the real cost in terms of memory might look like.



Exactly what 16 tasks, can we make an example
task/benchmark app to show it for discussion sake
i am curious as well and would love to do some
experiments here...

perkiset

Answered my own question by making this unnecessary.

I polished off my

Apache

  pseudo multithreading notion and posted about it here: http://www.perkiset.org/forum/

php

 /using_

php

 _the_webrequest2_class_and_

apache

 _for_multitasking-t773.0.html;msg5337

WAY WAY WAY Better solution and it is as fast as poop through a goose.


Perkiset's Place Home   Politics @ Perkiset's