Here are a Few Tips to increase performance of Node Application in Production.
- Avoid Disk Operations in Hot Path : No disk read/writes while processing the request from entry of request to server till the response is generated back. If you want to access environment variables , do that at the time of bootstrapping application and cache the data.
- Memory Profile your application : JS application are more vulnerable to memory leakages than statically typed languages. So its always advisable to memory profile your application run-time. If for constant load your memory usage is increasing then their is some leakage. (For constant load your memory usage must be a straight line parallel to x-axis.)
- CPU profile you application to identify heavy tasks and Offload them : CPU profile your node application for a fix amount of time and identify the tasks consuming more CPU cycles then others. Offload heavy tasks to some other async micro-service to keep the hot-path light and fast. (Crypto Tasks consume the most CPU cycles like Generating Hashes).
- Don't Gzip code using Node, Use Ngix/Apache which are better at it and Keep Node for processing only : Don't Gzip the html / response rendered on Node, instead use some web server to do it. Offload the task to web-server to keep Node free for handling requests.