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

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?
 
General rule is 96M for sites with image processing, and 128M for heavy php sites
Thus, 128M is my setting for XF
 
General rule is 96M for sites with image processing, and 128M for heavy php sites
Thus, 128M is my setting for XF
Thanks. Could you please inform about 'heavy php'? Would you consider xf framework as php heavy?
 
The PHP default is 128M. There's very little reason to change that in general. XF will attempt to set the memory limit itself.
 
The PHP default is 128M. There's very little reason to change that in general. XF will attempt to set the memory limit itself.
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).
 
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.
 
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).
If that's your situation, you have a lot of guest user's.
I highly recommend @xfrocks addon called BD Cache.
 
If that's your situation, you have a lot of guest user's.
I highly recommend @xfrocks addon called BD Cache.
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.
 
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.
 
Top Bottom