How to optimize postgres and the discourse DB

that does seem like a weird combo … 22GB memory but only 4 vcpu? Overkill on memory, but potentially too few cores.

normally you’d have a server with much more vcpu per GB

that’s because web serving is very parallel and for each unicorn you need only around 1GB.

Each Unicorn can run on a different core I believe.

This maybe why you are hitting 100% CPU utilisation so easily.

I’d recommend you consider moving to a 16/16 or even an 8/8 configuration and see if things improve.