#memory
39 messages · Page 1 of 1 (latest)
100% of how much?
do you have any recursive function or .map/.reduce/.foreach?
this is for registering of users,
with username/email validation if exist or not,
and saves to mongodb , that is all
100% CPU usage, in digitalocean
Average sized Nest apps consume around 300 MB, so if your total is half a gig, I'd say you're just below the limit
its 1gb
Also make sure you're starting just the built app with node dist/main. The npm layer adds some overhead.
do you think dockerizing it would help?
1 GB should be plenty for a mid sized app. I don't know how much pm2 and nginx consume together
im pretty sure that is some problem directly with the application and dockerize couldnt do much
what about rate limiting
i really appreciate the quick repsonse, this community is awesome
Dockerizing solves a completely different problem and certainly does not help with memory consumption.
i see
other point, how many times did you called the endpoint?
So you only see this high memory usage under heavy load, or during normal operation? Is someone ddosing the api?
it validates normally, however on success , it freezes due to cpu maxed out
and the rss logs is just increasing
im thinking theres a leak somewhere
this is process.memoryUsage btw..
Well, rate limiting can certainly help (nginx surely has some setting for that. If you already use nginx, you don't need to implement this in node). The other question is whether the stress test is warranted given your expected daily bandwidth and if you can tolerate degraded service when the demand is exceptionally high.
Another "solution" is to use asynchronous processing with queues.
But all that adds complexity and needs to be warranted given the "business" requirements
im thinking of rate limiting
but on a second thought, queues sounds fair
nah, its just the most basic crap out there, firs ttime deploying nestjs app lol
Rate limiting is much easier to implement, since you don't need to change the code flow. Asynchronous processing is a complex task, so I wouldn't get into it if you're just starting, unless you have experience with it from other languages, for example. It might be a great excercise though.
Yeah, i agree with @stoic cobalt, probably rate limit is a good first approach.
thanks a lot man, im not sure what i can give you for this responsive thread
but all i can say is you guys are better than chat gpt
😄
... for the time being 😅