Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


PHP script execution mode
New on LowEndTalk? Please Register and read our Community Rules.

All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.

PHP script execution mode

LAKidLAKid Member
edited March 2012 in General

Can anyone tell me which execution mode is better for low memory vps?

Apache mod_php (run as Apache's user)
CGI wrapper (run as virtual server owner)
FCGId (run as virtual server owner)

«1

Comments

  • tuxtux Member

    php-fpm

  • LAKidLAKid Member

    I noticed that /usr/bin/php-cgi eats a lot of ram, that's why...

  • It's probably because PHP encourages people to write crappy code.

  • LAKidLAKid Member

    Can php-Fpm be used in virtual environment such as webmin/virtualmin?

  • DamianDamian Member
    edited March 2012

    @rds100 said: It's probably because PHP encourages people to write crappy code.

    Nonsense!

    <?php
    
    $h = "h";
    $e = "e";
    $lone = "l";
    $ltwo = "l";
    $o = "o";
    
    $string = $h . $e . $lone . $ltwo . $o;
    
    print $string;
    
    ?>
    

    :D

    Thanked by 3Roph Derek Mon5t3r
  • @Damian here is some related fun :)

  • php-fpm plus ondemand scheduler n_n

  • @rds100 said: @Damian here is some related fun :)

    "Seasoned pro"
    OMFG!

  • And here is "Hello World" in a gazillion of different languages.

  • haha that's awesome. I was going to "Hello World" but it was too tiring

  • And here is some more :)

  • @rds100 said: It's probably because PHP encourages people to write crappy code.

    What? Register Globals is the BEST feature ever.

  • debugdebug Member

    @Damian said: @rds100 said: It's probably because PHP encourages people to write crappy code.

    Nonsense!

    <?php >$h = "h"; $e = "e"; $lone = "l"; $ltwo = "l"; $o = "o"; >$string = $h . $e . $lone . $ltwo . $o; >print $string; >?>
    :D

    Thats too easy!

    <?php
    // Making it easy for different langs!
    function h(){return "h";}
    function e(){return "e";}
    function l(){return "l";}
    function o(){return "o";}
    function w(){return "w";}
    function r(){return "r";}
    function d(){return "d";}
    function z(){return "!";}
    
    // sprintf is so cool!
    $stringone = "%s%s%s%s%s";
    $stringtwo = "%s%s%s%s%s";
    $stringthree = "%s";
    $stringfour = "%s %s%s";
    
    // If we need to change it...
    $command = "print";
    
    // Easy variable changing!
    $h = "h";
    $e = "e";
    $l = "l";
    $o = "o";
    $w = "w";
    $r = "r";
    $d = "d";
    ${null} = "z";
    
    // Let's build the string
    $string = sprintf($stringfour,ucfirst(sprintf($stringone,$h(),$e(),$l(),$l(),$o())),ucfirst(sprintf($stringtwo,$w(),$o(),$r(),$l(),$d())),sprintf($stringthree, ${null}()));
    
    // Lets do whatever with it!
    eval("$command($string)");
    ?>
    
    Thanked by 3vedran Roph klikli
  • @debug: You win!

  • AdamAdam Member

    php-fpm for frontend
    beanstalkd for backend tasks (resizing an image, etc)

  • LAKidLAKid Member

    did anybody actually use php-Fpm in virtual environment ?

  • @LAKid said: did anybody actually use php-Fpm in virtual environment ?

    Yes. It's using 15mb ram on my Xen VPS.

  • LAKidLAKid Member

    Apache mod_php uses 7 mb in openvz...

  • AdamAdam Member

    @LAKid mod_php doesn't scale as well.

  • @rds100 said: It's probably because PHP encourages people to write crappy code.

    That's like saying food encourages people to get fat.

    I don't disagree that there are many bad PHP scripts, but there are many good ones as well.

  • CloudxtnyHostCloudxtnyHost Member, Host Rep

    Guys check out Mod_ruid2. its the perfect balance of security and speed. Either that or check out MPM-ITK

  • DerekDerek Member
    edited March 2012

    @rds100 said: It's probably because PHP encourages people to write crappy code.


    foreach ($userList as $user) {
    $query = 'INSERT INTO users (first_name,last_name) VALUES("' . $user['first_name'] . '", "' . $user['last_name'] . '")';
    mysql_query($query);
    }

    Source - lolz

  • @Derek

    Good one, but sometimes you can't do that trickery without doing a loop :/

  • @Derek is it my idea or that's not security safe?

  • MrAndroidMrAndroid Member
    edited March 2012

    @OneTwo said: @Derek is it my idea or that's not security safe?

    That PHP code just does (Amount of Users) x MySQL Query.

    So if you have 25000 users, your running 25000 MySQL queries.

    The Google recommendation basically recommends you put it into one query, but then the fact that you have to add it all into an array, then implode it. So if you have 25,000 users thats going to be slow anyway.

    It also won't work with MySQL_insert_id.

  • exussumexussum Member
    edited March 2012

    Surely (firstname,lastname) values as a string.

    Then for(;;)
    $sql .= '(', $firstname ,',',lastname ,')';

    would be better ? Also check for sql injection

    Sorry on phone

  • I think the lowest memory usage is Apache mod_php (run as Apache's user).. I'm using it on my personal server.
    But prefer using FCGId (run as virtual server owner) on share environment (share with other user).
    Any other suggestion?
    Thanks..

  • dmmcintyre3dmmcintyre3 Member
    edited March 2012

    @Wira_Soenaryo said: I think the lowest memory usage is Apache mod_php (run as Apache's user).. I'm using it on my personal server.

    mod_php means every apache process has it's own php processor in it. That means every connection to apache needs at least 10-15mb ram. I often have 50-100 keepalive connections to my webserver. I would need almost 500mb-1GB ram for keepalives if I used mod_php.

  • fanfan Veteran

    PHP with uWSGI seems to be an interesting alternative, advertised to have better performance.

Sign In or Register to comment.