litespeed PHP memory_limit not being recognised ??

Discussion in 'Install/Configuration' started by eva2000, Feb 12, 2010.

  1. eva2000

    eva2000 Member

    Hi

    I seem to be stumped on a PHP memory_limit exceeded message of which the usual php.ini edits have no use.

    I've edited

    /usr/local/lib/php.ini
    /usr/local/lsws/php/php.ini

    Both to memory_limit = 256 and restarted lightspeed but still stuck around max 32-37MB for php ? Is this because php was compiled without memory-limit flag ?

    PHPINFO reports 256M memory_limit

    Code:
    memory_limit	256M	256M
    configure command

    but using test script as well as in drupal 5.19 and vbdrupal 5.19 scripts I am hitting memory_limit at around 32-37MB ??

    test script output

    phpmemory.php script contents

    Code:
    <?php
    // phpmemory.php
    
    $memlimit = 256;
    print 'Expected memory limit ' . $memlimit . 'MB <br />';
    
    $memory_mb = round(memory_get_usage() /1024/1024 , 2);
    print 'Base  -> ' . memory_get_usage() . ' (' . $memory_mb . ' MB)' . ' <br /> &ensp; <br />';
    
    $pattern = str_repeat("0123456789", 1000);
    $fill = str_repeat($pattern, 1);
    $counter = 1000;
    while ( $counter <= 27000 ) {
        unset($fill);
        $memory_mb = round(memory_get_usage() /1024/1024 , 2);
        print 'Clear -> ' . memory_get_usage() . ' (' . $memory_mb . ' MB) <br />';
    
        print $counter . ' x 10000 chars -> ' ;
        $fill = str_repeat($pattern, $counter);
        $memory_mb = round(memory_get_usage() /1024/1024 , 2);
        print  memory_get_usage() . ' (' . $memory_mb . ' MB)'. ' [' . $memory_pct = round($memory_mb /
    $memlimit *100 , 1) . ' percent]<br />';
        $counter = $counter + 500;
    }
    print '<br />If you can see this, the server can allocate something close to 256mb';
    ?>
    
    So is there are php memory limit in litespeed elsewhere that needs editing ? I tried copying php.ini over to /home/username as well and that didn't work either ?

    If php needs to be recompiled with memory limit flag, where do I recompile it from litespeed admin for web1 and web2 servers or from WHM easyapache ?

    Rest of details:

    On WHM/Cpanel 11.25.xx based server with litespeed 4.0.12 on 2x web servers load balanced using haproxy where load balancer ip is xxx.xx.xxx.x13

    Both web1 and web2 have:

    • PHP 5.2.12 + Eaccelerator
    • Memcached 1.2.8 and Memache 2.2.5 installed

    thanks

    George
    Last edited: Feb 12, 2010
  2. mistwang

    mistwang LiteSpeed Staff

    There is a memory limit configuration for lsphp5 external application, login to LSWS web console and check.

    eaccelerator memory is counted towards that limit.
  3. eva2000

    eva2000 Member

    Ah didn't know eccelerator memory is counted too !

    is that eaccelerator actual used memory or the max limit defined for eaccelerator that is counted ?

    thanks
  4. mistwang

    mistwang LiteSpeed Staff

    eaccelerator always allocate SHM/MMAP memory all at once at beginning.
  5. eva2000

    eva2000 Member

    eaccelerator was set at 256MB

    seems the soft/hard php5 limits in litespeed admin were 400M but I didn't know they were in bytes.. thought it was megabytes, so upped it to 2560 and it worked.
    Last edited: Feb 13, 2010
  6. eva2000

    eva2000 Member

    working with soft/hard limit at 1280 and 2560

  7. anewday

    anewday Moderator

    You can add a M for megabytes, which is the default.

    Like 300M
  8. eva2000

    eva2000 Member

    thats what was set in soft hard limits by default = 400M

    had to change it to 2560M to get to 256MB php.ini limit

    Attached Files:

    Last edited: Feb 13, 2010
  9. mistwang

    mistwang LiteSpeed Staff

    If eAccelerator is configured to use 256MB, the soft limit should be set above 512MB to leave 256MB for normal PHP usages. I think 600M should be enough by giving some head room.
  10. eva2000

    eva2000 Member

    hi having a problem now flowing on from original problem listed above.

    1. eaccelerator using 256MB assigned value

    2. now using above test script and drupal errors originally couldn't use more than 40MB when soft and hard limits were set to 400M by PHP5 external handler and memory_limit in php.ini set to 256MB

    3. raising the value to soft limits and hard limits of 1280M and 2560M allowed me to fix the script and drupal related memory exceeded limits of 37-40MB, BUT now the servers are getting 503 service unavailable messages maybe due to high soft/hard memory limits in PHP5 external handler ??? So is this a bug that 1280-2560M is needed to get 256M memory_limit to work ??

    4. Also we have memcache/memcached compiled and loaded memcache.so into php.ini. Memcached server set to allocate 128MB. Now found out php.ini had memcache.so loaded twice giving the below error message. Would this also drive up php memory usage to the point of 503 service unavailable messages ?

    Last edited: Feb 26, 2010
  11. mistwang

    mistwang LiteSpeed Staff

    if 503 error is due to consistent PHP process crash, you can add environment variable

    LSAPI_ALLOW_CORE_DUMP

    to lsphp5 external app configuration to let PHP dump a core file.
    http://www.litespeedtech.com/php-litespeed-sapi.html

    then check the core file with
    gdb /usr/local/lsws/fcgi-bin/lsphp5 core_file_name
    bt

    It lists the stack call backs when PHP crashes, you can get some clue from it.


    Latest 4.0.13 build reduce some 503 error for busy site. you can do a manual upgrade.
  12. csdco

    csdco New Member

    This seems like a bug. The 400M soft memory value is being recognized as 40 megabytes.
  13. webizen

    webizen New Member

    please elaborate or post your screenshot here.
  14. csdco

    csdco New Member

    Okay. With no opcode cache in place, I have used php.ini to set the memory limit to 512M. phpinfo() reports that this is the memory limit.

    When I run out of memory, say by working with a large data set, PHP reports that the allocated memory was just under 40M. How can this be? I checked the soft limit -- this was set to 400M. I changed this to 4000M and I'm able to perform the same task just fine.

    Edit: I also set this to 419430400 so that it would just use 400M defined in bytes and it works as expected. The "M" doesn't seem to be working as expected.
  15. webizen

    webizen New Member

    you can verify the softlimit by run 'ulimit -a' in php (see below). iow, make a request such as http://your.server.com/test.php and check the size of virtual memory which should reflect soft memory limit in lsphp5.
    # cat test.php
    <?php
    $ulimit=`ulimit -a`;
    echo "<pre>$ulimit</pre>";
    ?>
    Last edited: Jan 28, 2012
  16. Bono

    Bono New Member

    It looks like this feature is totally broken. In PHP config I have set 256MB memory limit I don't use any opcode cache until I fix this issue.
    In ext app for PHP 5 soft limit was 450 and now I raised it to 600MB.

    And if I check logs I see there is 128mb memory limit.

    [31-Jan-2012 13:39:25] PHP Fatal error: Out of memory (allocated 122683392) (tried to allocate 20314 bytes) in /home/site/public_html/libraries/joomla/database/database/mysql.php on line 462

    My memory stats:
    total used free shared buffers cached
    Mem: 3927 3665 261 0 185 1931
    -/+ buffers/cache: 1548 2378
    Swap: 2047 215 1831

    EDIT: now I raised soft to 600 and hard to 800 I get that I'm hitting limit at 256MB.
    Memory_limit in PHP is 256MB.

    [31-Jan-2012 14:45:48] PHP Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 24 bytes) in /home/site/public_html/libraries/joomla/database/database/mysql.php on line 462,

    Memory_limit in PHP is raised to 384MB, so now I will see what will happen.
    Last edited: Jan 31, 2012

Share This Page