Connecting Tech Pros Worldwide Help | Site Map

splitting a script over two servers

  #1  
Old April 12th, 2007, 05:05 PM
bleen
Guest
 
Posts: n/a
can someone point me in the right direction here..

I have a script (essentially a giant for loop) that takes about 20
mins to run on my server. I want "split" this process onto a second
server by doing something like this:

system("/srv1/path/to/php /path/to/script.php ".$arg1." ".$arg2." /
dev/null &");
system("/srv2/path/to/php srv1/path/to/script.php ".$arg1." ".$arg2."
Quote:
/dev/null &");
ideas? thoughts? questions? comments? concerns? jokes?

  #2  
Old April 12th, 2007, 06:25 PM
Erwin Moller
Guest
 
Posts: n/a

re: splitting a script over two servers


bleen wrote:
Quote:
can someone point me in the right direction here..
>
I have a script (essentially a giant for loop) that takes about 20
mins to run on my server. I want "split" this process onto a second
server by doing something like this:
>
system("/srv1/path/to/php /path/to/script.php ".$arg1." ".$arg2." /
dev/null &");
system("/srv2/path/to/php srv1/path/to/script.php ".$arg1." ".$arg2."
Quote:
>/dev/null &");
>
ideas? thoughts? questions? comments? concerns? jokes?
Yes:
Do you know why six is afraid of seven ?

.....
.....


Because 7 8 9.

;-)

Good luck.

Regards,
Erwin Moller
  #3  
Old April 12th, 2007, 07:05 PM
Steve
Guest
 
Posts: n/a

re: splitting a script over two servers


"bleen" <bleen67@gmail.comwrote in message
news:1176393365.880214.123040@y80g2000hsf.googlegr oups.com...
| can someone point me in the right direction here..
|
| I have a script (essentially a giant for loop) that takes about 20
| mins to run on my server. I want "split" this process onto a second
| server by doing something like this:
|
| system("/srv1/path/to/php /path/to/script.php ".$arg1." ".$arg2." /
| dev/null &");
| system("/srv2/path/to/php srv1/path/to/script.php ".$arg1." ".$arg2."
| /dev/null &");
|
| ideas? thoughts? questions? comments? concerns? jokes?

depends on what you're doing, don't it?

i'm sure you've already tried to split the work load on the SAME server
already...assuming the nasty thing you're wanting to avoid here is the 20
minute wait time. if not, try that...let your os optimize the processing.
other than that, what are you doing that takes 20 minutes...a foreach on a
1mb array on a 100mz i386 w/ 4mb of ram?


  #4  
Old April 12th, 2007, 07:45 PM
Rami Elomaa
Guest
 
Posts: n/a

re: splitting a script over two servers


bleen kirjoitti:
Quote:
can someone point me in the right direction here..
>
I have a script (essentially a giant for loop) that takes about 20
mins to run on my server. I want "split" this process onto a second
server by doing something like this:
>
system("/srv1/path/to/php /path/to/script.php ".$arg1." ".$arg2." /
dev/null &");
system("/srv2/path/to/php srv1/path/to/script.php ".$arg1." ".$arg2."
Quote:
>/dev/null &");
>
ideas? thoughts? questions? comments? concerns? jokes?
>
Well, here's an idea. I'm not saying it's a good idea.

<?php
if($_GET['first']) {
system("/srv1/path/to/php /path/to/script.php ".$arg1." ".$arg2." /
dev/null &");
} else if($_GET['second']) {
system("/srv2/path/to/php srv1/path/to/script.php ".$arg1." ".$arg2."
Quote:
/dev/null &");
} else {
?>
<html>
<body>
<img src="<?php echo $_SERVER['PHP_SELF'] ?>?first=1" />
<img src="<?php echo $_SERVER['PHP_SELF'] ?>?second=1" />
</body>
</html>
<?php } ?>

--
Rami.Elomaa@gmail.com

"Wikipedia on vähän niinq internetin raamattu, kukaan ei pohjimmiltaan
usko siihen ja kukaan ei tiedä mikä pitää paikkansa." -- z00ze
  #5  
Old April 12th, 2007, 10:05 PM
Moot
Guest
 
Posts: n/a

re: splitting a script over two servers


On Apr 12, 11:56 am, "bleen" <blee...@gmail.comwrote:
Quote:
can someone point me in the right direction here..
>
I have a script (essentially a giant for loop) that takes about 20
mins to run on my server. I want "split" this process onto a second
server by doing something like this:
>
system("/srv1/path/to/php /path/to/script.php ".$arg1." ".$arg2." /
dev/null &");
system("/srv2/path/to/php srv1/path/to/script.php ".$arg1." ".$arg2."
>
Quote:
/dev/null &");
>
ideas? thoughts? questions? comments? concerns? jokes?
What do you get when you cross a polar bear with a seal?
....
...
..
A polar bear!

And as for your question, it really depends on what you're trying to
do and if that work can be broken down into smaller pieces. You
should go through your script and try to break it out into as many
independent blocks as you can.

You say this is a giant for loop? Does the data need to be worked on
sequentially (ie: does the order of processing matter?). If not, you
can build up a queue of smaller jobs (one for each loop iteration in
your current script?), then offload one job to each server at a time.
When one server finishes, send it another job, etc, until they're all
done. Think of the way those Folding@Home/SETI@Home projects work.
They divide up work into chunks, send each chunk out for processing at
a random computer, and assemble the results into something meaningful
when they come back.

If you can't really split up the work, then you're SOL. I've got a
few of those scripts, myself and there's not much you can do about it.

  #6  
Old April 13th, 2007, 11:05 AM
Toby A Inkster
Guest
 
Posts: n/a

re: splitting a script over two servers


bleen wrote:
Quote:
system("/srv1/path/to/php /path/to/script.php ".$arg1." ".$arg2." /
dev/null &");
system("/srv2/path/to/php srv1/path/to/script.php ".$arg1." ".$arg2."
Quote:
>/dev/null &");
Ummm.... those will still run on the same server.

What you could do would be:

<?php
$r1 = file("http://server1/path/to/script.php?arg1={$arg1}&arg2={$arg2}");
foreach ($r1 as $R) print $R;
$r2 = file("http://server2/path/to/script.php?arg1={$arg1}&arg2={$arg2}");
foreach ($r2 as $R) print $R;
?>

--
Toby A Inkster BSc (Hons) ARCS
Contact Me ~ http://tobyinkster.co.uk/contact
Geek of ~ HTML/SQL/Perl/PHP/Python*/Apache/Linux

* = I'm getting there!
  #7  
Old April 13th, 2007, 01:15 PM
Jerry Stuckle
Guest
 
Posts: n/a

re: splitting a script over two servers


Toby A Inkster wrote:
Quote:
bleen wrote:
>
Quote:
>system("/srv1/path/to/php /path/to/script.php ".$arg1." ".$arg2." /
>dev/null &");
>system("/srv2/path/to/php srv1/path/to/script.php ".$arg1." ".$arg2."
Quote:
>>/dev/null &");
>
Ummm.... those will still run on the same server.
>
What you could do would be:
>
<?php
$r1 = file("http://server1/path/to/script.php?arg1={$arg1}&arg2={$arg2}");
foreach ($r1 as $R) print $R;
$r2 = file("http://server2/path/to/script.php?arg1={$arg1}&arg2={$arg2}");
foreach ($r2 as $R) print $R;
?>
>
But they'll still be processed sequentially, not in parallel.

You would want to start the scripts as above, but have run the processes
on other machines, i.e. with rsexec or similar.

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
comp.lang.c Answers to Frequently Asked Questions (FAQ List) Steve Summit answers 0 November 14th, 2005 07:46 PM
comp.lang.c Answers to Frequently Asked Questions (FAQ List) Steve Summit answers 0 November 14th, 2005 03:55 PM
comp.lang.c Answers to Frequently Asked Questions (FAQ List) Steve Summit answers 5 November 14th, 2005 12:36 PM
Roundup of FAQ change requests Richard Cornford answers 4 July 23rd, 2005 04:44 PM