This would appear to be a fairly general question of Linux server optimization, which is a complicated subject. The details of such optimization depend on a myriad of factors and settings and is, generally speaking, not the kind of thing that can be answered on a site like this--it depends as much upon the hardware as it does on the software and settings.
To optimize your server would require an analysis of your server and its details by a sysadmin with Ubuntu experience.