Server runs out of RAM – How to find cause

memory

My website seems to go down for up to an hour almost every day. My host says it's running out of RAM. I don't know much about servers so would appreciate advice on what to do next.

The website (3dsbuzz.com) has a WordPress section, Wiki, Gallery and a VBulletin forum each with their own custom code and plug-ins. So there are lots of potential places which could be inefficiently coded. It runs from a cloud server with 2GB of RAM. The MySQL database is 370MB. We get around 30,000 page views per day.

What would be the best way to reduce the amount of down time? Should I upgrade my server (I can't really afford to) or is 2GB reasonable? I have plenty of errors in my error log, but they don't always occur around the same times as the server going down, so I'm not sure how relevant it is.

Best Answer

2GB of RAM looks ok.

Some clues to check:

  • Database

    • Configure mysql to get slowlog - to find bottlenecks.
    • Check mysql engine.
      • If there is MyISAM - it could be problem because of whole table locks with writes (for example VBulletin could cause many writes).
      • If this is the problem - convert every table not using FULLTEXT index (or at least often changed tables) to InnoDb (or even better XtraDB from MariaDB or Percona)
  • Web serwer

    • Biggest problem could be apache with mod_php. (especially if because of mysql it top time requests beginning to lasts longer).
      • If you have this:
        • preferable switch to nginx.
        • If you cant - use fcgi php (preferable php5-fpm).

And consider hiring professional who can audit situation and help with configuration.