0

After a clean server reboot, the server will be okay. Upon visiting the website and clicking around on some links, apache2 processes are created but never terminated and it constantly takes up more and more memory until the server essentially crashes. The only way to fix this is to either restart the apache2 service in order to terminate all of the processes, or by rebooting the server again.

My attempts have included restoring to default WordPress theme and disabling all plugins, then browsing the website again, although it seems the issue persists after the fact. I've also attempted to make minor configurations to apache.conf as well as the php.ini file.

I'm rather lost at the moment and have done research in order to try and find out what the issue is but have only gone down dead ends.

My question is, why are apache2 and mysqld taking up so much memory and prevent them from doing so in order to stop my server from crashing?

Below is an image of the currently running processes, showing apache eating up memory and spawning several apache2 processes.

enter image description here

Apache Error Logs:

[Fri Aug 10 18:15:48.070518 2018] [mpm_prefork:notice] [pid 7451] AH00169: caught SIGTERM, shutting down
[Fri Aug 10 18:15:48.948516 2018] [ssl:warn] [pid 11222] AH01909: 127.0.1.1:443:0 server certificate does NOT include an ID which matches the server name
[Fri Aug 10 18:15:49.143749 2018] [ssl:warn] [pid 11223] AH01909: 127.0.1.1:443:0 server certificate does NOT include an ID which matches the server name
[Fri Aug 10 18:15:49.154471 2018] [mpm_prefork:notice] [pid 11223] AH00163: Apache/2.4.18 (Ubuntu) OpenSSL/1.0.2g configured -- resuming normal operations
[Fri Aug 10 18:15:49.154530 2018] [core:notice] [pid 11223] AH00094: Command line: '/usr/sbin/apache2'

mmap() failed: [12] Cannot allocate memory

mmap() failed: [12] Cannot allocate memory

(Repeat . . . )

Apache Access Logs (bots may be causing it?):

5.9.61.232 - - [10/Aug/2018:18:40:11 +0000] "GET /product-category/personalized-jewelry/page/10/?produ&product_count=3&product_orderby=rating&product_view=list HTTP/1.1" 200 374 "-" "Mozilla/5.0 (compatible; MJ12bot/v1.4.8; http://mj12bot.com/)"
5.9.141.8 - - [10/Aug/2018:18:40:13 +0000] "GET /product-category/personalized-jewelry/page/7/?produ=&product_orderb=&product_orderby=date&product_order=asc HTTP/1.1" 200 374 "-" "Mozilla/5.0 (compatible; MJ12bot/v1.4.8; http://mj12bot.com/)"
5.9.61.232 - - [10/Aug/2018:18:40:13 +0000] "GET /product-category/personalized-jewelry/page/10/?produ&product_count=3&product_view=grid&product_order=asc HTTP/1.1" 200 374 "-" "Mozilla/5.0 (compatible; MJ12bot/v1.4.8; http://mj12bot.com/)"
5.9.61.232 - - [10/Aug/2018:18:40:23 +0000] "GET /product-category/personalized-jewelry/page/10/?produ&product_count=3&product_view=grid&product_order=desc HTTP/1.1" 200 374 "-" "Mozilla/5.0 (compatible; MJ12bot/v1.4.8; http://mj12bot.com/)"
5.9.141.8 - - [10/Aug/2018:18:40:23 +0000] "GET /product-category/personalized-jewelry/page/7/?produ=&product_orderb=&product_orderby=date&product_order=desc HTTP/1.1" 200 374 "-" "Mozilla/5.0 (compatible; MJ12bot/v1.4.8; http://mj12bot.com/)"
5.9.61.232 - - [10/Aug/2018:18:40:29 +0000] "GET /product-category/personalized-jewelry/page/10/?produ&product_count=3&product_view=grid&product_orderby=date HTTP/1.1" 200 374 "-" "Mozilla/5.0 (compatible; MJ12bot/v1.4.8; http://mj12bot.com/)"
5.9.141.8 - - [10/Aug/2018:18:40:29 +0000] "GET /product-category/personalized-jewelry/page/7/?produ=&product_orderb=&product_orderby=date&product_view=grid HTTP/1.1" 200 374 "-" "Mozilla/5.0 (compatible; MJ12bot/v1.4.8; http://mj12bot.com/)"
5.9.141.8 - - [10/Aug/2018:18:40:34 +0000] "GET /product-category/personalized-jewelry/page/7/?produ=&product_orderb=&product_orderby=date&product_view=list HTTP/1.1" 200 374 "-" "Mozilla/5.0 (compatible; MJ12bot/v1.4.8; http://mj12bot.com/)"
5.9.61.232 - - [10/Aug/2018:18:40:34 +0000] "GET /product-category/personalized-jewelry/page/10/?produ&product_count=3&product_view=grid&product_orderby=default HTTP/1.1" 200 374 "-" "Mozilla/5.0 (compatible; MJ12bot/v1.4.8; http://mj12bot.com/)"
5.9.141.8 - - [10/Aug/2018:18:40:41 +0000] "GET /product-category/personalized-jewelry/page/7/?produ=&product_orderb=&product_orderby=default&product_count=16 HTTP/1.1" 200 374 "-" "Mozilla/5.0 (compatible; MJ12bot/v1.4.8; http://mj12bot.com/)"
5.9.61.232 - - [10/Aug/2018:18:40:41 +0000] "GET /product-category/personalized-jewelry/page/10/?produ&product_count=3&product_view=grid&product_orderby=name HTTP/1.1" 200 374 "-" "Mozilla/5.0 (compatible; MJ12bot/v1.4.8; http://mj12bot.com/)"
5.9.141.8 - - [10/Aug/2018:18:40:49 +0000] "GET /product-category/personalized-jewelry/page/7/?produ=&product_orderb=&product_orderby=default&product_order=asc HTTP/1.1" 200 374 "-" "Mozilla/5.0 (compatible; MJ12bot/v1.4.8; http://mj12bot.com/)"
5.9.61.232 - - [10/Aug/2018:18:40:49 +0000] "GET /product-category/personalized-jewelry/page/10/?produ&product_count=3&product_view=grid&product_orderby=rating HTTP/1.1" 200 374 "-" "Mozilla/5.0 (compatible; MJ12bot/v1.4.8; http://mj12bot.com/)"
5.9.61.232 - - [10/Aug/2018:18:40:55 +0000] "GET /product-category/personalized-jewelry/page/10/?produ&product_count=3&product_view=list&product_orderby=date HTTP/1.1" 200 374 "-" "Mozilla/5.0 (compatible; MJ12bot/v1.4.8; http://mj12bot.com/)"
5.9.141.8 - - [10/Aug/2018:18:40:54 +0000] "GET /product-category/personalized-jewelry/page/7/?produ=&product_orderb=&product_orderby=default&product_order=desc HTTP/1.1" 200 374 "-" "Mozilla/5.0 (compatible; MJ12bot/v1.4.8; http://mj12bot.com/)"
5.9.141.8 - - [10/Aug/2018:18:41:01 +0000] "GET /product-category/personalized-jewelry/page/7/?produ=&product_orderb=&product_orderby=default&product_view=grid HTTP/1.1" 200 374 "-" "Mozilla/5.0 (compatible; MJ12bot/v1.4.8; http://mj12bot.com/)"
5.9.61.232 - - [10/Aug/2018:18:41:01 +0000] "GET /product-category/personalized-jewelry/page/10/?produ&product_count=3&product_view=list&product_orderby=default HTTP/1.1" 200 374 "-" "Mozilla/5.0 (compatible; MJ12bot/v1.4.8; http://mj12bot.com/)"
5.9.61.232 - - [10/Aug/2018:18:41:10 +0000] "GET /product-category/personalized-jewelry/page/10/?produ&product_count=3&product_view=list&product_orderby=name HTTP/1.1" 200 436 "-" "Mozilla/5.0 (compatible; MJ12bot/v1.4.8; http://mj12bot.com/)"
5.9.61.232 - - [10/Aug/2018:18:41:12 +0000] "GET /product-category/personalized-jewelry/page/10/?produ&product_count=3&product_view=list&product_orderby=popularity HTTP/1.1" 200 374 "-" "Mozilla/5.0 (compatible; MJ12bot/v1.4.8; http://mj12bot.com/)"
5.9.141.8 - - [10/Aug/2018:18:41:10 +0000] "GET /product-category/personalized-jewelry/page/7/?produ=&product_orderb=&product_orderby=default&product_view=list HTTP/1.1" 200 374 "-" "Mozilla/5.0 (compatible; MJ12bot/v1.4.8; http://mj12bot.com/)"
5.9.141.8 - - [10/Aug/2018:18:41:14 +0000] "GET /product-category/personalized-jewelry/page/7/?produ=&product_orderb=&product_orderby=name&product_count=16 HTTP/1.1" 200 374 "-" "Mozilla/5.0 (compatible; MJ12bot/v1.4.8; http://mj12bot.com/)"
5.9.61.232 - - [10/Aug/2018:18:41:14 +0000] "GET /product-category/personalized-jewelry/page/10/?produ&product_count=3&product_view=list&product_orderby=price HTTP/1.1" 200 374 "-" "Mozilla/5.0 (compatible; MJ12bot/v1.4.8; http://mj12bot.com/)"
5.9.61.232 - - [10/Aug/2018:18:41:21 +0000] "GET /product-category/personalized-jewelry/page/10/?produ&product_count=3&product_view=list&product_orderby=rating HTTP/1.1" 200 374 "-" "Mozilla/5.0 (compatible; MJ12bot/v1.4.8; http://mj12bot.com/)"
5.9.141.8 - - [10/Aug/2018:18:41:21 +0000] "GET /product-category/personalized-jewelry/page/7/?produ=&product_orderb=&product_orderby=name&product_order=asc HTTP/1.1" 200 374 "-" "Mozilla/5.0 (compatible; MJ12bot/v1.4.8; http://mj12bot.com/)"
5.9.61.232 - - [10/Aug/2018:18:41:30 +0000] "GET /product-category/personalized-jewelry/page/2/?prod&product_count=16&product_order&product_orderby=name HTTP/1.1" 200 374 "-" "Mozilla/5.0 (compatible; MJ12bot/v1.4.8; http://mj12bot.com/)"
5.9.141.8 - - [10/Aug/2018:18:41:30 +0000] "GET /product-category/personalized-jewelry/page/7/?produ=&product_orderb=&product_orderby=name&product_order=desc HTTP/1.1" 200 374 "-" "Mozilla/5.0 (compatible; MJ12bot/v1.4.8; http://mj12bot.com/)"
5.9.61.232 - - [10/Aug/2018:18:41:36 +0000] "GET /product-category/personalized-jewelry/page/2/?prod&product_count=16&product_order&product_orderby=price HTTP/1.1" 200 374 "-" "Mozilla/5.0 (compatible; MJ12bot/v1.4.8; http://mj12bot.com/)"
5.9.141.8 - - [10/Aug/2018:18:41:36 +0000] "GET /product-category/personalized-jewelry/page/7/?produ=&product_orderb=&product_orderby=name&product_view=grid HTTP/1.1" 200 374 "-" "Mozilla/5.0 (compatible; MJ12bot/v1.4.8; http://mj12bot.com/)"
5.9.141.8 - - [10/Aug/2018:18:41:43 +0000] "GET /product-category/personalized-jewelry/page/7/?produ=&product_orderb=&product_orderby=name&product_view=list HTTP/1.1" 200 374 "-" "Mozilla/5.0 (compatible; MJ12bot/v1.4.8; http://mj12bot.com/)"
5.9.61.232 - - [10/Aug/2018:18:41:43 +0000] "GET /product-category/personalized-jewelry/page/2/?prod&product_count=16&product_order&product_orderby=rating HTTP/1.1" 200 374 "-" "Mozilla/5.0 (compatible; MJ12bot/v1.4.8; http://mj12bot.com/)"
5.9.61.232 - - [10/Aug/2018:18:41:51 +0000] "GET /product-category/personalized-jewelry/page/2/?product_count=16&product_orderby=date&product_view&product_order=asc HTTP/1.1" 200 374 "-" "Mozilla/5.0 (compatible; MJ12bot/v1.4.8; http://mj12bot.com/)"
5.9.141.8 - - [10/Aug/2018:18:41:51 +0000] "GET /product-category/personalized-jewelry/page/7/?produ=&product_orderb=&product_orderby=popularity&product_count=16 HTTP/1.1" 200 374 "-" "Mozilla/5.0 (compatible; MJ12bot/v1.4.8; http://mj12bot.com/)"
5.9.141.8 - - [10/Aug/2018:18:42:02 +0000] "GET /product-category/personalized-jewelry/page/7/?produ=&product_orderb=&product_orderby=popularity&product_order=asc HTTP/1.1" 200 374 "-" "Mozilla/5.0 (compatible; MJ12bot/v1.4.8; http://mj12bot.com/)"
5.9.61.232 - - [10/Aug/2018:18:42:02 +0000] "GET /product-category/personalized-jewelry/page/2/?product_count=16&product_orderby=default&product_view&product_order=asc HTTP/1.1" 200 374 "-" "Mozilla/5.0 (compatible; MJ12bot/v1.4.8; http://mj12bot.com/)"
5.9.141.8 - - [10/Aug/2018:18:42:10 +0000] "GET /product-category/personalized-jewelry/page/7/?produ=&product_orderb=&product_orderby=popularity&product_order=desc HTTP/1.1" 200 374 "-" "Mozilla/5.0 (compatible; MJ12bot/v1.4.8; http://mj12bot.com/)"
5.9.61.232 - - [10/Aug/2018:18:42:10 +0000] "GET /product-category/personalized-jewelry/page/2/?product_count=16&product_orderby=popularity&product_view&product_order=desc HTTP/1.1" 200 374 "-" "Mozilla/5.0 (compatible; MJ12bot/v1.4.8; http://mj12bot.com/)"
5.9.141.8 - - [10/Aug/2018:18:42:20 +0000] "GET /product-category/personalized-jewelry/page/7/?produ=&product_orderb=&product_orderby=popularity&product_view=grid HTTP/1.1" 200 374 "-" "Mozilla/5.0 (compatible; MJ12bot/v1.4.8; http://mj12bot.com/)"
5.9.61.232 - - [10/Aug/2018:18:42:20 +0000] "GET /product-category/personalized-jewelry/page/3/?product_count=16&product_orderby=date&product_view&product_order=asc HTTP/1.1" 200 374 "-" "Mozilla/5.0 (compatible; MJ12bot/v1.4.8; http://mj12bot.com/)"
5.9.61.232 - - [10/Aug/2018:18:42:26 +0000] "GET /product-category/personalized-jewelry/page/3/?product_count=16&product_orderby=default&product_v HTTP/1.1" 200 374 "-" "Mozilla/5.0 (compatible; MJ12bot/v1.4.8; http://mj12bot.com/)"
5.9.141.8 - - [10/Aug/2018:18:42:26 +0000] "GET /product-category/personalized-jewelry/page/7/?produ=&product_orderb=&product_orderby=popularity&product_view=list HTTP/1.1" 200 374 "-" "Mozilla/5.0 (compatible; MJ12bot/v1.4.8; http://mj12bot.com/)"
5.9.141.8 - - [10/Aug/2018:18:42:35 +0000] "GET /product-category/personalized-jewelry/page/7/?produ=&product_orderb=&product_orderby=price&product_count=16 HTTP/1.1" 200 374 "-" "Mozilla/5.0 (compatible; MJ12bot/v1.4.8; http://mj12bot.com/)"
5.9.61.232 - - [10/Aug/2018:18:42:35 +0000] "GET /product-category/personalized-jewelry/page/3/?product_count=16&product_orderby=rating&product_v HTTP/1.1" 200 374 "-" "Mozilla/5.0 (compatible; MJ12bot/v1.4.8; http://mj12bot.com/)"
5.9.141.8 - - [10/Aug/2018:18:42:41 +0000] "GET /product-category/personalized-jewelry/page/7/?produ=&product_orderb=&product_orderby=rating&product_view=grid HTTP/1.1" 200 374 "-" "Mozilla/5.0 (compatible; MJ12bot/v1.4.8; http://mj12bot.com/)"
5.9.61.232 - - [10/Aug/2018:18:42:41 +0000] "GET /product-category/personalized-jewelry/page/3/?product_count=16&product_orderby=rating&product_v&product_order=desc HTTP/1.1" 200 374 "-" "Mozilla/5.0 (compatible; MJ12bot/v1.4.8; http://mj12bot.com/)"
5.9.141.8 - - [10/Aug/2018:18:42:49 +0000] "GET /product-category/personalized-jewelry/page/7/?produ=&product_orderb=&product_orderby=rating&product_view=list HTTP/1.1" 200 374 "-" "Mozilla/5.0 (compatible; MJ12bot/v1.4.8; http://mj12bot.com/)"
5.9.61.232 - - [10/Aug/2018:18:42:49 +0000] "GET /product-category/personalized-jewelry/page/5/?prod&product_count=16&product_order=desc&product_orderby=date HTTP/1.1" 200 374 "-" "Mozilla/5.0 (compatible; MJ12bot/v1.4.8; http://mj12bot.com/)"
5.9.141.8 - - [10/Aug/2018:18:42:58 +0000] "GET /product-category/personalized-jewelry/page/7/?produ=&product_orderb=&product_view=grid&product_count=16 HTTP/1.1" 200 374 "-" "Mozilla/5.0 (compatible; MJ12bot/v1.4.8; http://mj12bot.com/)"
5.9.61.232 - - [10/Aug/2018:18:42:58 +0000] "GET /product-category/personalized-jewelry/page/5/?prod&product_count=16&product_order=desc&product_orderby=default HTTP/1.1" 200 374 "-" "Mozilla/5.0 (compatible; MJ12bot/v1.4.8; http://mj12bot.com/)"

closed as too broad by Rui F Ribeiro, G-Man, schily, Archemar, Isaac Aug 15 '18 at 7:55

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • More interesting than an image of htop at one instant in time would be some excerpts of the apache logs. – DopeGhoti Aug 10 '18 at 18:35
  • I've added the Apache logs to my post. – Rob Calaceto Aug 10 '18 at 18:41
  • Turn on swap. Please understand that you need swap, even on a machine with much more RAM than your current one. – peterh Aug 15 '18 at 20:58
  • Swap was not enabled on this server instance, although after enabling the swap file the issue persists. – Rob Calaceto Aug 16 '18 at 18:36
1

It looks like your site is being hit by a particularly aggressive web crawler. You might look to see if you can exclude or rate-limit your site from that bot, or block it at the firewall if it's not a bot you particularly care about. Alternatively, you could add a robots.txt file to your site to discourage such bots.

0

From the htop image I think mysqld is eating more memory than apache. I'm trying to provide some general solutions that may be helpful.

  1. Try tweaking mysqld parameters in /etc/my.cnf. Please google for how to reduce mysql memory consumption.

  2. I think memory footprint of apache/nginx + php-fpm is lesser than if you handle php directly with apache. In both cases, you can control the maximum number of php thread, memory per thread etc. Please do some fine tuning there.

  3. Most importantly analyze mysqld, apache2 etc log files. Read man pages for default log file locations and find for any error.

Hope, that's help.

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