#[OPTYMALIZATION] what can i do to make better performance with nestjs app?

3 messages · Page 1 of 1 (latest)

potent niche
#

I mean less usage of CPU or RAM.

For example when i have an endpoint that generates pdf and calcualte something. and the pdf is as buffer in resposne - its pretty heavy.

I thought about adding cluster by pm2 and pm2 start app.js -i 4 but it helped nothing. result with timing was the same when i run endpoint 50 times by symulator w 4 instanecs of app as with one instance

Meybe other infos? The second thing what i thought to improve performence was using cache and move endpoints with refreshing new notifications to websockets

tulip quest
#

You can try caching on your server (ex. Nginx server) and caching on your NestJS app at the same time, this will help a lot but you have to be careful of not returning the same results to two diff users.

You can also make use of Promise.all() for doing multiple things at the same time and improve speed.

https://blog.appsignal.com/2021/11/24/7-ways-to-improve-nodejs-performance-at-scale.html
Read this

AppSignal Blog

Read some practical tips to help you scale your Node.js application to handle more traffic.