Newbie question: How can I find the process which is consuming all of the available virtual memory?

Hi

I'm sorry for this newbie question, beceause I'm new to the Linux, and I did a search on the forum, but maybe my keyword was not exact so that I wasn't found any tips I wish.

Today I received the following error message when I visit my wordpress website

Warning: mysqli_real_connect(): (HY000/2002): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) in /..../wp-includes/wp-db.php on line 1444

Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in /..../wp-includes/wp-db.php on line 1474

Warning: mysql_connect(): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) in /..../wp-includes/wp-db.php on line 1474

I restarted the server, and now the website is working fine, however, I don't understand what's mean about the errors, so I opened a ticket and received the following reply:

> Your Linode was OOMing, meaning something inside your node is consuming all of the available virtual memory. You can see this for yourself by logging into Lish and viewing the output of the "logview" command within the console [0].

These messages you see written to your console indicate that your Linode had exhausted its allotted RAM resources and invoked the OOM-Killer. The OOM-Killer is designed to identify the highest scoring processes and kill them in order to free up memory required by the system.

When you rebooted your Linode, it came back online - however, you will want to take measures to optimize your services to reduce your overall RAM and swap usage. To begin with, I'd suggest implementing the low-memory settings advised in our Troubleshooting guide to minimize your risks of OOMing again [1].

But I don't know why when I enter "logview" command, it shows "logview: command not found", so how can I find out the process which is consuming all of the available virtual memory?

Thanks

6 Replies

The process which is taking all your memory is almost always Apache in prefork mode using mod-php. (You can use the "top" command to check, then press capital M).

Try switching to Nginx + PHP-FPM. See the thread below this one:

~~[https://forum.linode.com/viewtopic.php?f=20&t=11978" target="_blank">](https://forum.linode.com/viewtopic.php?f=20&t=11978](

@sanvila:

The process which is taking all your memory is almost always Apache in prefork mode using mod-php. (You can use the "top" command to check, then press capital M).

Try switching to Nginx + PHP-FPM. See the thread below this one:

~~[https://forum.linode.com/viewtopic.php?f=20&t=11978" target="_blank">](https://forum.linode.com/viewtopic.php?f=20&t=11978](

Thanks for your reply, is there any way to improve the server configuration without switching to Nginx, because I don't want to make website offline, I don't have secondary hosting.

If your Apache is >= 2.4, you can use Apache + PHP-FPM, and it would also be an improvement over your current setup.

The offline time depends on how fast you can change the configuration and restart Apache.

If you use a little bit of scripting, it should not take more than a few seconds, a minute at most.

Use a test linode to experiment.

@johnnywoo:

@sanvila:

The process which is taking all your memory is almost always Apache in prefork mode using mod-php. (You can use the "top" command to check, then press capital M).

Try switching to Nginx + PHP-FPM. See the thread below this one:

~~[https://forum.linode.com/viewtopic.php?f=20&t=11978" target="_blank">](https://forum.linode.com/viewtopic.php?f=20&t=11978](

Thanks for your reply, is there any way to improve the server configuration without switching to Nginx, because I don't want to make website offline, I don't have secondary hosting.

Do a search in this forum for MaxClients, this question is asked very frequently. Simple answer is to try dropping your MaxClients to 30, possibly lower. The default is way too high

@sanvila:

If your Apache is >= 2.4, you can use Apache + PHP-FPM, and it would also be an improvement over your current setup.

The offline time depends on how fast you can change the configuration and restart Apache.

If you use a little bit of scripting, it should not take more than a few seconds, a minute at most.

Use a test linode to experiment.

You don't need Apache 2.4+. I'm using Apache 2.2.15 with the worker MPM and PHP-FPM, and it works great.

Switching to Nginx is probably not worth it. Just switch to the worker or event MPM instead of prefork.

Ok, you don't need Apache 2.4, but then you will need some "extras".

Apache 2.4 is the first release where you do not need any "extras".

https://wiki.apache.org/httpd/PHP-FPM
> we can now run secure, fast, and dependable PHP code using only the stock apache httpd and php.net releases; no more messing around with suphp or suexec - or, indeed, mod_php.

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct