popen - command line vs. web server performance

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • yawnmoth

    popen - command line vs. web server performance

    say i have the following two php scripts:

    ptest.php:
    <?
    $p1 = popen("c:\\php\ \php -q hello.php","r") ;
    $p2 = popen("c:\\php\ \php -q hello.php","r") ;
    while (!feof($p1))
    print fgets($p1);
    while (!feof($p2))
    print fgets($p2);
    pclose($p1);
    pclose($p2);
    ?>

    and

    hello.php:
    <?
    print "hello,\nworld! \n";
    ?>

    when i run ptest.php via the command line (ie. by typing in c:\php\php
    ptest.php at the dos prompt) it runs instantly.

    when i run ptest.php via a webserver, the resultant page not only
    doesn't even load - it results in a bunch of errors (that appear as
    dialogue boxes on the machine doing the hosting) effectively saying
    that the command failed to execute properly and will now be shut down.
    after clicking through all the errors, the systems performance is
    noticebly affected (and in fact is bad enough such that i think a
    reboot is justified).

    any ideas as to why this is, and what i can do to fix it?
  • Pjotr Wedersteers

    #2
    Re: popen - command line vs. web server performance

    yawnmoth wrote:[color=blue]
    > say i have the following two php scripts:
    >
    > ptest.php:
    > <?
    > $p1 = popen("c:\\php\ \php -q hello.php","r") ;
    > $p2 = popen("c:\\php\ \php -q hello.php","r") ;
    > while (!feof($p1))
    > print fgets($p1);
    > while (!feof($p2))
    > print fgets($p2);
    > pclose($p1);
    > pclose($p2);[color=green]
    >>[/color]
    >
    > and
    >
    > hello.php:
    > <?
    > print "hello,\nworld! \n";[color=green]
    >>[/color]
    >
    > when i run ptest.php via the command line (ie. by typing in c:\php\php
    > ptest.php at the dos prompt) it runs instantly.
    >
    > when i run ptest.php via a webserver, the resultant page not only
    > doesn't even load - it results in a bunch of errors (that appear as
    > dialogue boxes on the machine doing the hosting) effectively saying
    > that the command failed to execute properly and will now be shut down.
    > after clicking through all the errors, the systems performance is
    > noticebly affected (and in fact is bad enough such that i think a
    > reboot is justified).
    >
    > any ideas as to why this is, and what i can do to fix it?[/color]

    Did you look at taskmanager to see what causes the poor performance ? Must
    be some process hogging the cpu, would help to see if it has to do with
    apache (or IIS?) Other than that, is it a typo here or does your hello.php
    miss a ? before the end > ???


    Comment

    • yawnmoth

      #3
      Re: popen - command line vs. web server performance

      "Pjotr Wedersteers" <x33159@westert erp.com> wrote in message news:<416a4bc1$ 0$78279$e4fe514 c@news.xs4all.n l>...[color=blue]
      > yawnmoth wrote:[color=green]
      > > say i have the following two php scripts:
      > >
      > > ptest.php:
      > > <?
      > > $p1 = popen("c:\\php\ \php -q hello.php","r") ;
      > > $p2 = popen("c:\\php\ \php -q hello.php","r") ;
      > > while (!feof($p1))
      > > print fgets($p1);
      > > while (!feof($p2))
      > > print fgets($p2);
      > > pclose($p1);
      > > pclose($p2);[color=darkred]
      > >>[/color]
      > >
      > > and
      > >
      > > hello.php:
      > > <?
      > > print "hello,\nworld! \n";[color=darkred]
      > >>[/color]
      > >
      > > when i run ptest.php via the command line (ie. by typing in c:\php\php
      > > ptest.php at the dos prompt) it runs instantly.
      > >
      > > when i run ptest.php via a webserver, the resultant page not only
      > > doesn't even load - it results in a bunch of errors (that appear as
      > > dialogue boxes on the machine doing the hosting) effectively saying
      > > that the command failed to execute properly and will now be shut down.
      > > after clicking through all the errors, the systems performance is
      > > noticebly affected (and in fact is bad enough such that i think a
      > > reboot is justified).
      > >
      > > any ideas as to why this is, and what i can do to fix it?[/color]
      >
      > Did you look at taskmanager to see what causes the poor performance ? Must
      > be some process hogging the cpu, would help to see if it has to do with
      > apache (or IIS?) Other than that, is it a typo here or does your hello.php
      > miss a ? before the end > ???[/color]

      yeah - that was a typo. the actual hello.php file has it. anyway,
      looking at task manager, i see that a *bunch* of php and cmd processes
      are being created, and none are ending. so, what i assume happening
      is that the computers memory is just being exhausted.

      i tried to replace print "hello,\nworld\ n" with
      exit("hello,\nw orld!\n") to no avail.

      the exact error i get is as follows:

      The application failed to initialize properly (0xc0000142). Click on
      OK to Terminate.

      i get that for both php.exe and cmd.exe.

      in contrast, when i run it from the command line, it takes place so
      fast that i don't see any process being created.

      Comment

      • Chung Leong

        #4
        Re: popen - command line vs. web server performance

        "yawnmoth" <terra1024@yaho o.com> wrote in message
        news:a0d63404.0 410101216.791b7 79e@posting.goo gle.com...[color=blue]
        > say i have the following two php scripts:
        >
        > ptest.php:
        > <?
        > $p1 = popen("c:\\php\ \php -q hello.php","r") ;
        > $p2 = popen("c:\\php\ \php -q hello.php","r") ;
        > while (!feof($p1))
        > print fgets($p1);
        > while (!feof($p2))
        > print fgets($p2);
        > pclose($p1);
        > pclose($p2);
        > ?>
        >
        > and
        >
        > hello.php:
        > <?
        > print "hello,\nworld! \n";
        > ?>
        >
        > when i run ptest.php via the command line (ie. by typing in c:\php\php
        > ptest.php at the dos prompt) it runs instantly.
        >
        > when i run ptest.php via a webserver, the resultant page not only
        > doesn't even load - it results in a bunch of errors (that appear as
        > dialogue boxes on the machine doing the hosting) effectively saying
        > that the command failed to execute properly and will now be shut down.
        > after clicking through all the errors, the systems performance is
        > noticebly affected (and in fact is bad enough such that i think a
        > reboot is justified).
        >
        > any ideas as to why this is, and what i can do to fix it?[/color]

        Could be a DLL incompatibility problem. The DLL search path in Windows, if I
        remember correctly, goes like this: the current folder, the folder
        containing executable, the system32 folder. If your webserver is running a
        different version of PHP than the command line one, then the wrong DLL could
        get loaded. Do a search for php4ts.dll and see if there're multiple copies.


        Comment

        • yawnmoth

          #5
          Re: popen - command line vs. web server performance

          On Tue, 12 Oct 2004 01:09:58 -0400, "Chung Leong"
          <chernyshevsky@ hotmail.com> wrote:
          [color=blue]
          >"yawnmoth" <terra1024@yaho o.com> wrote in message
          >news:a0d63404. 0410101216.791b 779e@posting.go ogle.com...[color=green]
          >> say i have the following two php scripts:
          >>
          >> ptest.php:
          >> <?
          >> $p1 = popen("c:\\php\ \php -q hello.php","r") ;
          >> $p2 = popen("c:\\php\ \php -q hello.php","r") ;
          >> while (!feof($p1))
          >> print fgets($p1);
          >> while (!feof($p2))
          >> print fgets($p2);
          >> pclose($p1);
          >> pclose($p2);
          >> ?>
          >>
          >> and
          >>
          >> hello.php:
          >> <?
          >> print "hello,\nworld! \n";
          >> ?>
          >>
          >> when i run ptest.php via the command line (ie. by typing in c:\php\php
          >> ptest.php at the dos prompt) it runs instantly.
          >>
          >> when i run ptest.php via a webserver, the resultant page not only
          >> doesn't even load - it results in a bunch of errors (that appear as
          >> dialogue boxes on the machine doing the hosting) effectively saying
          >> that the command failed to execute properly and will now be shut down.
          >> after clicking through all the errors, the systems performance is
          >> noticebly affected (and in fact is bad enough such that i think a
          >> reboot is justified).
          >>
          >> any ideas as to why this is, and what i can do to fix it?[/color]
          >
          >Could be a DLL incompatibility problem. The DLL search path in Windows, if I
          >remember correctly, goes like this: the current folder, the folder
          >containing executable, the system32 folder. If your webserver is running a
          >different version of PHP than the command line one, then the wrong DLL could
          >get loaded. Do a search for php4ts.dll and see if there're multiple copies.[/color]

          Thee's only one. I'm actually thinking that this is a bug in PHP. I
          was told by my webhost to stop using a similar script because it kept
          crashing their browser. Could other people test it out, and post
          here, whether or not it works? Also, if it is a bug, how does one go
          about filling a bug report?

          Comment

          Working...