Site going down due to lack of memory

Keywords: WordPress - AWS - Technical issue - Services (Apache, MariaDB, MySQL…)

bndiagnostic ID: 12345678-abcd-1234-abcd-123456789abc

bndiagnostic failure reason: I was unable to run the tool, it used up the little remaining memory and crashed.

Description:
First off, I tried running the Bitnami Diagnostics Tool, but this crashed the server.

I tried to create this topic about the Bitnami Diagnostics Tool as your prompt suggests, but this seems broken as I was unable to proceed to create the topic.

I run a low traffic WordPress site on t2.micro with 1GB of RAM which should be an has been ample for the traffic up until a few days ago, when the server started going down.

Since I don’t seem to be able to edit my original post, here’s some more information.

Server has been running fine with no memory issues running the various jobs, backups etc. until a couple days ago, when almost any process (deleting 20 records, performing a backup, processing an image etc.) uses up all available memory and makes the site unresponsive/down all together.

After a restart of the server available memory is high. But after ~5min available memory drops and the server becomes unresponsive, regardless of which plugins I disable.

I’ve been checking memory use by running:

  • htop -m
  • ps -e -orss=,args= | sort -b -k1,1n | pr -TW$COLUMNS

Things I’ve tried:

  • Blocking IPs spamming certain URLs, as-per your docs
  • Placing site into Cloudflare “Under Attack” mode to prevent any DDoS
    (this makes no difference - even when no traffic the server is running out of memory)
  • Setting up Redis object cache to improve query performance
  • Disabling plugins and re-enabling one by one

Any chance someone could take a look at my server? Since I’m unable to run the diagnostics tool, I’m happy to provide any information you need via PM.

Hi @alecrust ,

As we do not have the bndiagnostic information, we suggest you take a look at this other thread

You can try to run the bndiagnostic tool after stopping the services

sudo /opt/bitnami/ctlscript.sh stop
sudo /opt/bitnami/bndiagnostic-tool
sudo /opt/bitnami/ctlscript.sh start

@jota thanks for your reply. I hadn’t considered stopping all services before running the diagnostics tool. Doing this, it just about managed to complete after a couple hours. Here’s the ID:

738fa016-6947-e44b-9ac4-47f57d534f1c

Would you mind taking a look? Please bear in mind:

  • I have essentially blocked all traffic to the site during testing, and checked/blocked spamming requests, so it doesn’t seem to be a DoS attack.
  • I shouldn’t need to increase the resources for this machine, the site gets low traffic and does very little. I have made no changes - the site was running fine then started grinding to a halt.

Hi @alecrust ,

I can see there are a lot of errors with pagespeed in the Apache’s log and that means that the instance is running out of RAM memory. If you couldn’t run the Diagnostic tool when the services were running, that supports my assumption. Please increase the resources or check if there is any bot/attacker accessing your site. You will also need to increase the number of processes PHP-FPM can launch, I see errors in the PHP-FPM’s log file

I can see there are a lot of errors with pagespeed in the Apache’s log and that means that the instance is running out of RAM memory

Yes, the instance is definitely running out of memory.

Please increase the resources

As stated, the instance doesn’t need more memory it does very little. It’s been running with ample excess memory for years, and I had made no changes when this started happening.

or check if there is any bot/attacker accessing your site.

I have prevented all access to the site with DoS protection, followed your docs to block attackers etc. and the issue remains. I’ve rules out 3rd party requests bringing it down. Due to the memory issue/leak any internal process that starts doesn’t any available memory, due to mysql and php-fmt using it all.

You will also need to increase the number of processes PHP-FPM can launch, I see errors in the PHP-FPM’s log file

Yes, the errors in the PHP-FPM log file happen because basically no process has no memory with which to run.

To be clear, this isn’t a scaling issue, there is no increase in traffic, 1GB of RAM on such a basic WordPress site is more than enough as I’m sure you know.

As you mentioned, there are lots of errors with pagespeed. Perhaps pagespeed is the culprit bringing the site down. My question is why would that start happening all of a sudden :sweat_smile:

Correct, 1GB of RAM should be enough but I do not know if any of the plugins you have is generating so many requests that is making the instance to run out of memory. That’s something you will need to review.

Let’s disable PageSpeed, sometimes it fails due to incompatibilities with the app/plugins

https://docs.bitnami.com/aws/apps/wordpress/administration/use-pagespeed/#disable-pagespeed

Thanks @jota I have disabled pagespeed and things seem to be running better. Also bumped my max_children and that error occurs less often in the logs now.

As you say perhaps a plugin was causing many requests. Though when disabling them I was unable to identify a specific problem plugin, so pagespeed still looks the most likely issue.

Still unknown as to what “broke pagespeed” such that it started consuming all memory. If it’s known to cause issues (or “break randomly after years”) maybe it should be removed from the stack.

Thanks again!

Hi @alecrust,

I’m glad to hear it’s working. Thanks for sharing the solution.

Regards,
Michiel