ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

RPGLE calling PHP taking a long time...

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • RPGLE calling PHP taking a long time...

    We recently upgraded a program running under ZendCore to the new Zend Server 8.5.5. Our box iSeries 7.1.

    The RPGLE program calls a PHP script that calls an UPS API and validats addresses. We are using this UNIX :


    Code:
    Fphppipe UF F 1000 SPECIAL PGMNAME('UNIXCMD')
    F PLIST(UNIXPARM) USROPN 
    
    [COLOR=#000000][FONT=Arial]cmd = 'PATH=$PATH:/usr/local/zendsvr6/bin && +
    iconv -f 37 -t 819 | +
    php-cli /www/zendsvr6/htdocs/CORE/UPS/xmlTest4.PHP';[/FONT][/COLOR]

    On ZendCore is ran fast but now that we switched to Zend Server 8.5.5 it's taking on average about 7 seconds to return the results. Calling the same PHP script from a browser it returns the results right away. We add curl_getinfo($ch)' to see the details of the cURL request and they look the same. It just appears it's the initial interaction between the RPGLE & PHP where we're seeing this add time. As far as the PHP script we're using STDIN.


    PHP Code:
    //define STDIN
    if(!defined"STDIN" ) ){
      
    define"STDIN"fopen'php://stdin''r' ));
    }

    //start standinput
    $input trim(fgets(STDIN));

    //explode data on unique separator
    $get_data explode('!'$input); 
    Any thoughts on why we'd see this added time?


  • #2
    I have some thoughts, though I can't account for why this would take 7 seconds. (That seems like an extremely long time.)

    When you run it through the web server, Zend Server is already pre-loaded into the computer's memory. When the request comes, it only has to run your PHP script, it does not have to load PASE or Zend Server because they are already pre-loaded into memory using a technique called "FastCGI".

    By contrast, when you use UNIXCMD, it has to create a child job om which to run PASE. Then, it has to run php-cli which loads a copy of Zend PHP into memory, and finally it can run your script. So it makes perfect sense that there would be additional overhead when running it through UNIXCMD. I would expect this only to take one second or less, not 7 -- but perhaps your system is also slower or busier than mine?

    Since the web method seems to run better for you, you could consider running your PHP as a web service rather than a command-line script. That should make the performance the same as running it from the browser.

    Comment


    • #3
      When you say run PHP as a web service.. would that something like REST/SOAP? Is there a way to run PHP via the UNIXCMD so it runs in memory/fastcgi instead of it running in the PASE environment?

      Comment


      • #4
        REST and SOAP are styles of web services, yes. But, of course, you can have any sort of web service you like, you're not limited to one of those. My point was not to force you to adhere to some standard, but rather was to solve your performance issue. You told me that PHP performs poorly from the command-line, but performs well from HTTP -- it makes sense, therefore, to call it from HTTP to get the faster performance... doesn't it?

        It's unclear to me why you'd want to invoke FastCGI from UNIXCMD? I guess it'd be POSSIBLE... you just get an HTTP client that's designed for a Unix command line and run it via UNIXCMD -- but this seems like a lot of extra work, jumping through extra hoops, etc... and adding another layer of complexity for no reason at all. Why not just do the HTTP request directly from your RPG program?

        Comment


        • #5
          Sorry.. I am new to the RPG world - I spend most of my time in PHP. How would I do an HTTP request directly from RPG?

          Comment

          Working...
          X