Forum Moderators: coopster

Message Too Old, No Replies

Can't process multiple simultaneous scripts?

         

ChainsawXIV

8:10 am on Jan 20, 2008 (gmt 0)

10+ Year Member



I'm trying to develop a set of scripts that displays the activity in an IRC channel as part of a web page. The design I've been working with has three parts: the front end page, a server script which delivers content to the front end using AJAX, and a second PHP script which runs continually, putting content from the IRC channel into the $_SESSION where it can be accessed by the AJAX server side script. Like so:

Front End <- AJAX -> AJAX Script <- $_SESSION -> IRC Script

I have all three parts of this working individually, but the problem I'm encountering in my testing is that I can only get one script to execute at a time. So, while the IRC listener script is running (which it will be doing continuously through out the session), the AJAX server side script will never be processed.

I don't know what the root of this issue is, or how to fix it, so I'm hoping someone here can give me a little insight. Do I need to make configuration changes to PHP, Apache, or my scripts? Is this not actually a fixable problem? Your help would be greatly appreciated.

phparion

6:56 am on Jan 21, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



PHP does not support multi-threading.

You need to utilize web server / CLI, on *nix box, to run scripts in parallel.

[edited by: eelixduppy at 5:56 pm (utc) on Jan. 21, 2008]
[edit reason] removed URL [/edit]

ChainsawXIV

4:31 pm on Jan 22, 2008 (gmt 0)

10+ Year Member



I'm running this via Apache on windows (my local test setup). Am I understanding you correctly that this should just work on a nix setup, but won't work at all hosted on windows?

[edited by: ChainsawXIV at 4:40 pm (utc) on Jan. 22, 2008]

phparion

5:07 pm on Jan 22, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



'pure' multithreading is not possible in PHP. PHP5 somehow claims to handle multithreading but at the same time Zend recommends not to use PHP 5 with apache 2 due to multithreading limitations.

According to my experience, php-parallel-processing is not possible on Windows.

If anyone has done it please post here to upgrade my knowledge too.

thank you

phparion

5:12 pm on Jan 22, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



by the way, if you are good with AJAX-PHP then you can find a work-around.

run your php processes with javascript in parallel. I cannot post link to a site due to forum charter so please open google.com and write 'javascript multithreding' and follow the third link, at least third for me.

Achernar

5:54 pm on Jan 22, 2008 (gmt 0)

10+ Year Member Top Contributors Of The Month



One thing you may overlook is that two scripts can't open the same session at the same time. If the session is already opened (and not closed) by another process, the second process that tries to open it will wait until it is released.

ChainsawXIV

3:27 pm on Jan 23, 2008 (gmt 0)

10+ Year Member



Phparion, I'm not sure I'm reading the correct link (a forum post on the Microsoft forums). If I am, I'm either missing something obvious, or just not thinking in the right direction. Either way, I don't understand how multithreading my javascript will help me here. Can you give me some insight into how this might solve the issue?

Achernar, thanks for that information. Obviously, I hadn't got far enough to run into that problem yet, but it definitely puts a kink in my plans. Is there a way to move temporary data between scripts (and even across multiple sessions) that you can recommend? The only obvious solution would be databasing it, but that seems like a poor option when I don't actually want to store the data.