@jmeowmeow
Without knowing anything at all about your problem, I’d definitely consider whether your site (or some parts of it) can be statically generated offline. Code that runs once per data update instead of once per request solves a whoooole lot of problems.
(And keep in mind that you can even statically generate an API sometimes! One project I still maintain has a read-only REST API that’s actually just a bunch of .json files served by a vanilla web server.)