1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

PHP Memory Size: How do we decide the optimum size?

Discussion in 'Server Configuration and Hosting' started by TheBigK, Mar 2, 2014.

  1. TheBigK

    TheBigK Well-Known Member

    Did a quick search on the forum; but could not find the exact information I'm looking for. Yesterday we ran into 'out of memory' errors; because PHP was consuming about 80 MB of data. It was because of an add-on.

    I'm however curious to know what exactly should be our php memory setting? How do we decide it?
     
  2. Mouth

    Mouth Well-Known Member

    General rule is 96M for sites with image processing, and 128M for heavy php sites
    Thus, 128M is my setting for XF
     
  3. TheBigK

    TheBigK Well-Known Member

    Thanks. Could you please inform about 'heavy php'? Would you consider xf framework as php heavy?
     
  4. Mouth

    Mouth Well-Known Member

    No.
    But once you install addons, then you are introducing lots more load as far as SQL and caching etc.
     
    TheBigK likes this.
  5. Floren

    Floren Well-Known Member

    For XF the minimum is 128M, I use 256M.
     
  6. TheBigK

    TheBigK Well-Known Member

    Thanks. Does it depend on the overall RAM available in the system?
     
  7. Floren

    Floren Well-Known Member

    No. I think Mike uses also 256M on these forums.
     
  8. TheBigK

    TheBigK Well-Known Member

    Umm, is there any way to find out? Guess, I'll have to tag @Mike . Would really appreciate your input, sire!
     
  9. Mike

    Mike XenForo Developer Staff Member

    The PHP default is 128M. There's very little reason to change that in general. XF will attempt to set the memory limit itself.
     
    TheBigK likes this.
  10. TheBigK

    TheBigK Well-Known Member

    What's the best way to deal with php 'Out of Memory' errors? We got them on our site when the traffic spiked to about 6000 simultaneous users (~25 logged in members and rest all guests).
     
  11. Mike

    Mike XenForo Developer Staff Member

    Out of memory means that PHP couldn't allocate memory. Either you have an allocation limit smaller than PHP's limit or your server is out of memory (or couldn't allocate it for some reason).

    Assuming it's a legit out of memory issue, the specifics of what to do vary a lot, but they do involve analyzing how much memory an active connection takes. If you can't reduce that (depending on configuration), you need to consider reducing the maximum number of active connections to prevent overloading the server or simply adding more memory.
     
    TheBigK likes this.
  12. RoldanLT

    RoldanLT Well-Known Member

    If that's your situation, you have a lot of guest user's.
    I highly recommend @xfrocks addon called BD Cache.
     
  13. TheBigK

    TheBigK Well-Known Member

    Well, I guess I had that add-on enabled when the downtime happened. It was @xfrocks who helped figuring out that 'Members Online Now' widget was responsible for eating up all the memory.

    I think I've got a few leads to fixing this problem.
     
  14. RoldanLT

    RoldanLT Well-Known Member

    And also try Xen Cache addon.
    It will also help a lot for Big Boards.
     
  15. WSWD

    WSWD Well-Known Member

    There is no magic number. Allocate as much as you possibly can. If you have 32GB of RAM, are you really going to allocate 128M or 256M to PHP? That's just plain silly. There's no optimum size, there's no general rule, there's no magic number.
     
    TheBigK likes this.

Share This Page