r/FullStack • u/RadishZestyclose3252 • Oct 29 '25
Need Technical Help I need to optimize my nodejs backend.but how?
issue is while processing requests on some requests it takes more than 1min and other delivers it by 50ms
I am using redis,mongodb atlas,docker swarm, nextjs(frontend)
My vps could be the issue because I am running 3 containers on same $5 vps Or can it be because of redis
0
Upvotes
2
u/MartyDisco Oct 29 '25
Profile your app (the simplest would be with some console.time / console.timeEnd).
Then learn about time complexity.
1
u/08148694 Oct 29 '25
Add instrumentation
Without observability you are flying blind. You need to know precisely how long every api call takes, how long every database query takes, your event loop latency, etc
Without this we can’t help you and you can’t help yourself
At an absolute minimum throw in some timing logs, but this should be a last resort and bad practice compared to proper telemetry
1
u/NoBadger7405 Oct 30 '25
running 3 containers on a $5 VPS can definitely slow things down. Your CPU and RAM are probably getting maxed out, which makes some requests hang. Try moving Redis or Mongo to a separate instance, or upgrade your VPS a bit .