0

As you would have guessed I have a server setup with mod_php and Apache2 (prefork) with APC . The site receives decent amount of traffic daily and on highest being 280-290 users at the same time. A few days back I started to notice "Can't Allocate Memory" issues with PHP, which weren't happening during low traffic.

General solution for this is to increase the memory limit for PHP in the PHP.ini file. I wanted to know how would that effect performance and overall scalability when I increase the memory limit.

Server Capacity: 8gb Ram, Quad Core i7 ( 920 )

    StartServers          80
    MinSpareServers       40
    MaxSpareServers      60
    MaxClients          250
    MaxRequestsPerChild   200
Rishav
  • 220
  • 2
  • 10

1 Answers1

1

General solution for this is to increase the memory limit for PHP

No. It might be the right solution in some cases, but you've not provided any details of your analysis. That you don't know the consequences of increasing the memory limit implies that your analysis of the cause of the problem may be wrong.

Both with the original and the cyclic-reference checking GCs, increasing the memory limit will reduce the frequency of garbage collection leading to more garbage being kept in memory. The result (in some cases) is that it increases memory starvation problems.

You've not provided any real information about how much resources your system is using / how much are available.

280-290 users

This metric is pretty much irrelevant to capacity / performance.

NB I'm not asking you to provide the information needed for a fuller analysis - to make an informed recommendation, this is much, MUCH more than should ever be in a post here.

The short answer is try it and see what happens to your performance / errors.

A longer answer is that you might want to have a look elsewhere - at your code / compression / caching.

symcbean
  • 19,931
  • 1
  • 29
  • 49
  • I agree. I am still trying to understand what metrics to start to look at, because the pages that throw "Allocate memory" errors don't do that in low traffic ( which is weird to me ). Do I need to run straces on apache process or a "top" result, looking at how / which apache threads are clogging it. Because the details on the web for such analysis is very limited and I am as of yet unable to find an expert in this area. I am a make shift server admin and trying to atleast to learn the tools to get the correct picture. Or what would help me monitor it. – Rishav Mar 20 '13 at 15:46
  • I have used new relic before and it doesn't. I no longer want to throw hardware at the problem and move on. I thinks its obvious from the question that I am a total noob in these things, so if you any insight into what the right direction looks like, it will be great. Thanks for answering anyway. I can also only run limited level of experiments I because its a live production server. Thanks again for answering. – Rishav Mar 20 '13 at 15:50
  • Start tracking your free memory (less VFS) and number of Apache processes to find out how your memory relates to demand. Make sure you're using short keepalives and gzipping everything compressible (using mod_delate, not the PHP gz handler) and ensure that all your php scripts use output buffering (you can add this via an auto-prepend file rather than editing all your scripts. Your maxclients seems very low given the spec hence the uot of memory errors are even more confusing. But it makes no sense to start 80 servers and only allow 60 spare. – symcbean Mar 20 '13 at 22:36