#are there any "tips and tricks" doc out there for optimizing NestJS applications?

1 messages · Page 1 of 1 (latest)

placid geyser
#

hey there, as the title says, are there any documents out there that showcase some possible things people can do to improve performance in improving their APIs?

I know this is obviously dependent on the application but just want to know if there's something that lists that stuff

fickle bone
#

My list:

meager hare
# placid geyser hey there, as the title says, are there any documents out there that showcase so...

I don't think there are any general guides or articles that can cover everything about performance optimization. Eventually, you must go down the rabbit hole and gain experience. CatWow

In general, follow the best node/ts coding practices. Always use the latest LTS version of Node and other dependencies.

Avoid adding unnecessary packages and logic to the application.

If packages offer the same functionality, compare their benchmarks to choose what performs the best. For example, Fastify over Express, or Nestia or Zod over CV

Don't install development dependencies in the production environment.
Use a logging package that suits the production environment rather than the default one and set the logging level to error.

Try reducing the payload size the application sends or receives on the network. This can also include fetching unnecessary fields from the data source.

Take advantage of caching, streams, events, queues, and background jobs techniques if possible.

And lastly, as Vinicius said, reverse proxies are your friend!
You don't have to do everything on the nestjs application itself
It would help if you always left handling SSL traffic, rewriting routes, compressions, serving static files, load balancing, and other things to a reverse proxy. That way, your application will perform better and scale easier.

fickle bone
#

Reading what Script said I remember something, if you use AWS (or Nginx I think works too), you can connect your API with Cloudfront and cache any API Response with Cache-Control, this can handle millions of request easily and your API will only receive a few requests, I even wrote an article about this: https://viniciusl.com.br/posts/2022/12/08-from-million-invocations-to-thousand-with-correct-caching/

First, the results A journey on how I went from that amount of invocations in a voting system: For that number of invocations, making 2x as…

placid geyser
#

appreciate all the insight, it's all very helpful

kindred urchin