On a server with 30GB of memory serving somewhat high-volume traffic.

For some reason recently Apache2 has started running threads with insane memory usage. 500MB-750MB per thread is not uncommon right now.

php.ini has memory_limit = 128M (php7.0 default).

Apache prefork config is on defaults.

The result is that we're running with only ~1GB of free memory.

What am I missing?

We have Nginx proxying requests and it's processes are more like ~60MB per thread. Here is a screenshot of running top

Top Screenshot

Any insight as to what could be driving this is appreciated!


From that top output it looks like Apache processes have 20-50MB "res" (resident) in memory. The "virt" isn't memory you need to worry about, generally, it can be mapped files and isn't actual RAM used.

I can see that you have 28GB of memory "cached". This is typically cached files. This is a good thing, it saves the OS from having to go to the disk to access files.

I think you may benefit from the "Linux Ate My RAM" website.

What exactly is the problem this is causing? Does your system every report "out of memory", or processes fail because of lack of RAM?

  • The cached memory thing makes sense now. Sorry - I'm not much of an infrastructure guy. Biggest challenge is having nginx 504 timeouts recently - trying to narrow down the possible performance bottlenecks. – Wes Jun 21 '17 at 18:57
  • For your 504's, you might try to capture netstat -aeenp as root periodically during these times. Count the number of connections in time wait, close wait, etc. This is sometimes hard to spot in logs. If that is the issue, I can offer suggestions for a way around it. – Aaron Jun 21 '17 at 19:14
  • It's a common misunderstanding. Suggest you gather information and post a question about the timeouts. curl showing the problem, applicable logs, and configurations would be key information to share. – Tim Jun 21 '17 at 19:14
  • You probably mean MB, not KB up there, since the numbers are in kilobytes already. – Tollef Fog Heen Jun 21 '17 at 20:33
  • Thanks @TollefFogHeen, I wasn't sure what the units were – Tim Jun 21 '17 at 20:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.