Server easily goes out of memory

Discussion in 'Installation/Configuration' started by webmarker, Apr 21, 2013.

  1. webmarker

    webmarker New Member

    Hi I run Debian 6 with Apache. I'm in a vps with 1 gb RAM + 1 gb Swap and I noticed that is very easy to block all the services of the vps. It's enough to keep pressing CTRL+R for 1 minute in the home page of a fresh Joomla Installation to make freeze the whole vps for out of memory (it goes from 210 mb ram + 70 mb swap used, to 1015 mb ram + 1000 mb swap used). I dont think that's normal, how can I fix it? Should I use nginx?
     
  2. webmarker

    webmarker New Member

    Also Clamav uses a lot of memory, since I dont use mailserver should I stop it? Do I need it?
     
  3. webmarker

    webmarker New Member

    I've just monitored the processes during the holding of CTRL+R and it looks like that the systems creates a lot of php-cgi and apache2 processes and each one tries to take over 60% of ram. Any fix for this?
     
  4. darinpeterson

    darinpeterson Member

    Have you configured the VM yourself, or is the configuration provided by a hosting company?

    Here are my container settings:
    Code:
    PHYSPAGES="0:586755"
    SWAPPAGES="0:1173510"
    
    KMEMSIZE="unlimited"
    DCACHESIZE="unlimited"
    LOCKEDPAGES="unlimited"
    PRIVVMPAGES="unlimited"
    SHMPAGES="unlimited"
    NUMPROC="unlimited"
    VMGUARPAGES="0:unlimited"
    OOMGUARPAGES="0:unlimited"
    NUMTCPSOCK="unlimited"
    NUMFLOCK="unlimited"
    NUMPTY="unlimited"
    NUMSIGINFO="unlimited"
    TCPSNDBUF="unlimited"
    TCPRCVBUF="unlimited"
    OTHERSOCKBUF="unlimited"
    DGRAMRCVBUF="unlimited"
    NUMOTHERSOCK="unlimited"
    NUMFILE="unlimited"
    NUMIPTENT="unlimited"
    
    I'm pretty sure I could get it to run with only 1GB of memory... I run all services with no issues now, where physpages is available RAM, and swappages is 2X the actual allocated memory.

    I adjusted the settings to:
    Code:
    PHYSPAGES="0:500000"
    SWAPPAGES="0:1000000"
    
    restarted the server, and the server is working fine...

    This is what I used for my Debian 6 install: http://www.howtoforge.com/perfect-server-debian-squeeze-with-bind-and-dovecot-ispconfig-3.

    My hardware node runs CentOS 6.4, and only 4GB of RAM, where I run 3 OpenVZ virtual servers. Two name servers and the one that has the full configuration from the howto above.
     
  5. webmarker

    webmarker New Member

    Hi thanks for your reply I'm on a vps and I dont think I can access those settings and I used the same tutorial as yours to setup my server. Do you have any problem running a cms like joomla and holding CTRL+R to refresh the page? Do you think that it could be a problem of my vps provider?
     
  6. darinpeterson

    darinpeterson Member

    Hi webmarker,

    No, sorry. I don't run Joomla or any other form of CMS on the system. Even so, I highly doubt that it would lock up my system to refresh the page multiple times.

    Best regards,
    Darin
     
  7. till

    till Super Moderator Staff Member ISPConfig Developer

    1GB Ram is not that much for a server that uses apache + mail and FTP server. Also the speed of the system depends on how many other vm's are running on the same hardware node, e.g. if the Harddisk IO is high because there are many other vm's running on the same node, then you might get problems like you described.

    To protect your server against being overloaded, you can install mod_evasive.

    To speed up php processes, ensure that you use php mode php-fpm or php-fastcgi and not cgi or suphp and install a php binary cache like apc or xcache.
     
  8. darinpeterson

    darinpeterson Member

    Till,

    If you have a minute to reply, can you please put your recommendation, based on your experience for a full server install without DNS but including mail, and for an install with everything except mail and DNS server?

    Thanks,
    Darin
     
  9. falko

    falko Super Moderator Howtoforge Staff

    That depends on your workload, but generally I#d want my server to have at least 4GB of RAM.
     
  10. webmarker

    webmarker New Member

    I installed nginx and now looks like that everything works fine. Is there a mod_evasive for nginx too? Or something similar?
    I dont use mail server (I use just DNS+Web), should I uninstall clamav ? Do I need it? (it takes a lot of memory)
     
  11. darinpeterson

    darinpeterson Member

    For nginx mod_evasive, look here: http://stackoverflow.com/questions/4849094/mod-evasive-for-nginx

    If you don't need mail, I recommend the following:

    For step 10:
    Code:
    apt-get install mysql-client mysql-server openssl rkhunter
    
    vi /etc/mysql/my.cnf  // comment out the bind line
    
    /etc/init.d/mysql restart
    
    netstat -tap | grep mysql
    
    Skip step 11

    And no need to install SquirrelMail, ignore step 18.

    Good luck,
    Darin
     
    Last edited: Apr 27, 2013

Share This Page