I have Magento2 website on production mode. And i have 8gb ubuntu 16.04 server. But i have checked ram memory uses 99% so my website is working slow.

Please any one tell me why used my memory 99%?

Which module take lots of memory in Magento?

  • Are you using dadicated server or shared server? – Saphal Jha May 21 at 6:01
  • So have you checked your access logs for unusual traffic, check for the processes spiking RAM? – Raj Mohan R May 21 at 7:25
  • I am using dedicated hosting @SaphalJha – Masud Shaikh May 21 at 8:01
  • could you please try this command and post results: free -m or this command when you have high load: top | head -n 5 – MagenX May 21 at 8:30
  • @MagenX I have checked mysqld take lots of memory – Masud Shaikh May 21 at 12:11

first you need to understand your memory allocation and database status.

enable magento profiler:


check your data:

mysqlcheck -u root -p --all-databases

check your database using mysqltuner script: https://github.com/major/MySQLTuner-perl/blob/master/mysqltuner.pl

login to mysql shell and check tables size:

     table_schema as `Database`, 
     table_name AS `Table`, 
     round(((data_length + index_length) / 1024 / 1024), 2) `Size in MB` 
FROM information_schema.TABLES 
ORDER BY (data_length + index_length) ASC;

you can also open database in phpMyAdmin and sort tables by size. There are many tables too big? Some tables you can safely truncate. especially logs and debug data.

another option is to see actually what mysql is doing: install mytop monitoring tool. now you see all the threads. are they running too long, red color?

cd /usr/local/src
wget -qO - ${MYTOP} | tar -xzp && cd mytop*
perl Makefile.PL && make && make install 

mytop config file /root/.mytop:


now after you can see the picture. either your mysql my.cnfconfiguration is wrong, and you allocating memory incorrectly, or your database is broken or tables/data corrupted, maybe some bots are heavily drilling your bad custom scripts or code, or you just need to add more ram to your server.


You should check below things with your database:

  • Check for the log tables and truncate them Optimize Magento Database: https://magento2x.com/optimize-magento-database-by-cleaning-log/

  • Customer session should be set to file not to the database

  • Check mysql query execution time and check which query taking long time

  • Check with magento profiled to specific section execution time

  • if you are using varnish cache then try to switch it to mangento build-in cache and check and compare the performance.

  • check for the cron, if it is running in every 5 minute the check the scheduled cron.

May be this will help you, because you will have to figure out the things one by one manually.

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.