On occasion, my Backdrop website will go down. When you visit the site, you get the following error message: "SQLSTATE[08004] [1040] Too many connections." It's intermittent and usually goes away within a few minutes. But it's been happening more frequently since the last Backdrop update. That could just be a coincidence, but I wanted to see if anyone has suggestions about what's going on.

At least at first glance, this appears to be a hosting issue. I have two other websites on the same shared hosting plan, both built in WordPress, and when the Backdrop site goes down, the WordPress sites go down as well, with a different message ("Error establishing a database connection.")

But the WordPress sites are tiny, just a few pages each, whereas the Backdrop site is massive, with thousands of pages.

I've gone round and round with my hosting provider. Here are some of their suggestions:

"Too many connections is typically a temporary issue that can occur when your website experiences a peak in resource usage."

"If the issue persists, we strongly recommend reducing factors that may contribute to excessive connections, such as limiting the number of cron jobs and disabling any unnecessary plugins."

"Currently, your websites are loading correctly, and their current resource usage is within normal limits. The SQLSTATE[08004] [1040] Too many connections error typically means the database hit its connection limit. However, we did not find any significant traffic spikes or server issues during the reported time."

"Given that this is an intermittent issue, it may be caused by bots or crawlers overloading the server." (In response to their suggestions, I modified robots.txt to ban a list of AI crawlers and increased crawl delay from 10 to 30 seconds. But the problem persisted.)

Though I'm on a shared hosting plan, it's the highest-performing and (and costliest) plan offered by my provider, Hosting.com (formerly A2 Hosting). I use a free Cloudflare plan for content delivery on the Backdrop site, but not the WordPress sites. This has been happening intermittently since I relaunched the main site in Backdrop, but it's gotten worse in the past week.

Most helpful answers

Also, when we had some problems with the Backdrop sites, this is what the server admin did:

I have increased the max_connections for mariadb and increased the child_processes for php-fpm.

Have you enabled caches on the site at:

Admin Bar > Configuration > Development > Performance

(admin/config/development/performance)

Are there any complex Views that show on all pages? (A quick look at your site doesn't look like this is the case)

Check what errors you are logging (admin/config/development/logging) and maybe deselect "Notice" and "Info"

The WordPress sites may be tiny, but it is possible they could be the target for bots so is there anyway to check those?  

Comments

Have you enabled caches on the site at:

Admin Bar > Configuration > Development > Performance

(admin/config/development/performance)

Are there any complex Views that show on all pages? (A quick look at your site doesn't look like this is the case)

Check what errors you are logging (admin/config/development/logging) and maybe deselect "Notice" and "Info"

The WordPress sites may be tiny, but it is possible they could be the target for bots so is there anyway to check those?  

Thanks for the suggestions. All caches have been enabled from the start.

I'm not sure what qualifies as a "complex" view. There are 400-500 pages that include EVA fields. But the vast majority of pages contain no Views at all.

I went ahead and deselected "Notice" and "Info" in logging. Virtually all log messages are "page not found" errors, most likely generated by search engine crawlers looking for pages that have been deleted. The logs are showing lots of those, around 1000 every two days.

Also, when we had some problems with the Backdrop sites, this is what the server admin did:

I have increased the max_connections for mariadb and increased the child_processes for php-fpm.

This is helpful. When I Googled for suggestions about the error message, I found an old entry in Stack Overflow that suggested increasing max_connections. I passed that along to the hosting provider's tech support but haven't heard back from them. I tried to see if I could do it myself in CPanel or via FTP but couldn't find a way to access the config file.