There is a virtual server with 512 MB of RAM. Ubuntu 14, Apache 2.4.7, MySQL, and other programs for running a small django site .. + php

From time to time there are messages of this content:

"low RAM. Apache2 process and 2 others killed by OOM-killer." or "lack of RAM. Apache2 process killed by OOM-killer."

displayed in events in the server control panel ..

I am attaching resource usage statistics: screenshot

It is seen that during normal operation, there is enough memory for the eyes. But at some point there is a surge in memory and intensive reading from the disk. OOM-killer is triggered at this moment.

How to deal with it? How to understand exactly who causes such a load?

  • Using CentOS? - cheops
  • cheops, Ubuntu 14 - Vladimir
  • is swap enabled? This will explain the surge in disk activity - they got into the swap, and then that was not enough. More remarkable are LA bursts and CPU loads, but no burst over the network. It means that it is not just flowing, but doing something. What is in dmesg? There should be more information. Then, access and error logs of the web server. I don’t remember if Apache can write an error if his descendant kills OOM, but in theory he should write this into the log. - Minor

1 answer 1

Good day. First, the problem may not only be in Apache. OOM-killer has a system for assessing the importance of processes, on the basis of which it makes a decision about which process is to be destroyed. You have many different services on one server, so I strongly recommend checking out the work of MySQL and "other programs for a small django site". Although if you know that the memory occupied by Apache is growing, you may not be distracted by it. If you are not sure that Apache is eating up the memory, I recommend paying attention to slow MySQL queries . Here the logic is simple - the faster the request is executed, the faster the memory will be freed.

Now about apache. You need to check the server logs - perhaps the memory growth is associated with a surge of some requests. If this is the case, further actions will depend on such requests. Try also using the worker event . And also - to set lower limits on the number of connections / processes - in this case, with the growth of requests, some clients will not be able to connect to the server, but this will save it from falling.

Well, one more touch - try replacing Apache with nginx. Well, or supplement it with nginx, as a front end (i.e., a server that accepts external requests and sends them to the server behind it).