Large UniFi Installs: How to Tune the Controller for High Number of Devices

I have been through this video many times and folowed the steps buy my controller is still running at 100%

I have 3 cores and 16gb of ram on the ubuntu server.

Problem is that Java runs at 100% of CPU. Actually the unifi controller does not crash, it just uses 100% of the resources. Ram is also using all available.

I have setup a new server and restored the backup also and the same thing happens.