

This is the job for the OS.
You can run most Linux systems with stupid amounts of swap and the only thing you’ll notice is that stuff starts slowing down.
In my experience, only in extremely rare cases are you smarter than the OS, and in 25+ years of using Linux daily I’ve seen it exactly once, where oomkiller killed running mysqld processes, which would have been fine if the developer had used transactions. Suffice to say, they did not.
I used a 1 minute cron job to reprioritize the process, problem “solved” … for a system that hadn’t been updated for 12 years but was still live while we documented what it was doing and what was required to upgrade it.


Build a website on your preferred platform, you’re already using WP.
Create a static version of it. There’s plugins for exactly that purpose.
Put the static files on a web host, I use s3, but you can use whichever you prefer.
When you update the site on WP, run the static extraction again and update your actual site.