Discourse stuck with 504 Gateway Time-Out error and 100% CPU after rebuild

Thanks. I didn’t realise that I could increase the memory on the droplet and then reverse it (as long as the disk size isn’t changed). I increased the memory temporarily to 8GB and everything started working as expected, with a CPU of 2-5% (see screenshot below), but when I reverted back to 2GB, which has always worked fine on a forum which only has very light use, the same issue returned with 100% CPU (see screenshot). How could I address this issue without permanently increasing the memory?