How to optimize the usage of CPU, RAM in Centos


I have setup in AWS cloud with Centos, and its running fine for me, but sometimes I have message like insufficient memory to process the java file, anyone can help me to optimize the CPU, RAM in Centos

a) How to get the CPU Usage
b) How to kill unwanted Process in centos
c) How to reduce the RAM memory on the fly

Note: used new relic to monitor the instance, but not satisfied, Please advice thanks


fallow the below link

fallow the below article

you can get cpu load by using the monitoring commands like