WordPress: Management of the memory and the resources

WordPress: Management of the memory and the resources

By all it is known that WordPress is a CMS, and therefore in addition to the files that are located in the space corresponding Web, and to which we can accede through service FTP, also is necessary a data base that it connects to the CMS. So that WordPress works this data base must communicate with the space Web, and the consultations and the communication between both parts must be most fluid possible.

For a correct and safe connection of ours hosting towards his own data base wordpress located in localhost, we must have well-taken care of with the amount of plugins that we installed within the CMS, since each plugin generates requests to that data base, and therefore hosting or Web server is consuming resources of ours. If we did not control the management of the memory and the resources, ours hosting or Web server, can turns affected by:

  • Falls of the service mysql
  • Tips of load in the ram memory
  • Excess use of the processor

In the case of having contracted for our Web hosting, VPS or something similar, the resources of the physical machine are shared and limited, therefore we must take care of and save these resources. In case we use a dedicated physical servant is more complicated than they occur this kind of problems, although a process €œzombie€ can put in tail of processes, and enter a curl which never it will leave, increasing exponentially the load of RAM and being able to originate a fall of the service. This comes being very current in Ddos attacks or attacks by refusal on watch.
An example: the typical attack to the vulnerability of WordPress that tries to create great amount of users simultaneously, making work in excess to mysql, until the service is interrupted and falls.

WordPress: Management of the resources and to drain Ram memory

His it is to have installed in an external servant a system of monitoring as Nagios, but good, also our suppliers of hosting usually offer some quite acceptable alternative to us to receive alert by mail in case of falls of services: mysql, ssh, FTP, video streaming€¦ or fallen completes - > ping does not respond.

Within the Control Panel of ours hosting or servant must appear a monitoring in real time of the resources, but he is not thus also through ours cpanel or plesk we can throw a look to how the resources of the machine are flowing. In case of observing something strange, we will accede by ssh to solve it:

Step by step to drain the memory and the resources:

We are going to see as it is the subject from the monitorizador of our supplier of services and from plesk:
monitorizador ram

and now from plesk:
monitorizador ram plesk

I know this server, and the ram enough is collapsed (46% of use are too much for him, because 32 WordPress are two working here and only have gb of ram), must exist some process zombie, or something nonhabitual. In order to see that it is happening we entered the machine via ssh, for it we opened a terminal and we wrote: ssh root@ obvious replacing by the IP of your server. (in these captures I erase ip's to maintain the privacy of host)

connection ssh

Next I execute the commando: top to see as is the processes that are consuming me more ram, and we already observed that something referring to mysql is shown this way, I try to do: service mysqld restart, but the thing follows equal so we are going to prove another different solution.

I monitor the ram from the terminal so that indeed of 32gb of ram of the server, almost half this being used, which knowing my machine seems to me strange:
For it I execute the commando: free - m and says to us just like plesk:
free - m

Well because we are going to come to drain the ram of the server with this commando:
to drain ram

Now we return to see the used ram and€¦ Ta ta ta chan!
free - m

We go to plesk to verify that from here all this OK also
monitorizador ram plesk

Solution | Prevention for falls of WordPress

In this occasion the problem was the ram, also we can see the processes in execution with ps aux, and kill those that are suspicious, but with taken care of logically.
The processes kill with the commando Kill + the number of the process that the same ps aux generates to you in screen.

In order out of danger to maintain better the security and the resources of ours hosting before possible problems with processes and memory, associate these recommendations:

  • To hide wp-admin of wordpress for external attempts of login
  • To form firewall to close the door to problems and external connections
  • To use plugin wordpress optimize database to after revisions, to maintain cleaning the data base.

If you liked this article or she served as help comp¡rtelo please to you.
A greeting,
By “scar Carrillo