Troubleshoot performance issues on WordPress/WooCommerce site

The website is having intermittent resource usage problems. It will run fine for a few days, then suddenly show huge spikes in resource usage, leading to 524 and “cant establish database connection” errors. The start of the problem seems to be specifically associated with activity in the admin area, although the entire website is affected once the problem starts.

The site has LiteSpeed enabled, and has caching through Cloudflare, on the server, and on the website. It has a plugin to optimize the database and remove expired transients nightly. It’s also using ElasticSearch to help with the admin load times.

A problem was previously found with a plugin that caused time-out errors on the Add/Edit Product pages, but that was resolved a month ago and all was fine until this week.

I’ve done all that I can think of, as has my hosting company. The site is hosted on a VPS so there should be more than enough resources, yet it still occasionally goes rampant and consumes all available resources, maxing out the CPU, and often crashing the database under the weight of rapidly proliferating MySQL processes.

According to my host, the website is showing high resource use on every page, which isn’t terribly helpful in narrowing the problem down. Sorry. They’ve suggested that it might be a problem with a poorly-written script, but I have no idea where to even start looking for that.

Thank you.