DEV Community


Discussion on: How would you tackle this NodeJS project?

ahmedmagdy11 profile image
Ahmed Magdy

it's probably bad practice aka bad code that lead to memory leaks.. i would suggest to read about bad practices that lead to this kind of behaviour and refactor the code from there. recognizing the wrong or bad pieces of code will be a lot way faster to fix.

hasnaindev profile image
Muhammad Hasnain Author • Edited

Thanks! But isn't that the point though? If I use Bubble Sort in order to sort an array because I don't know about Merge Sort at that point, regardless of how I write code, I'm stuck with the slow O^2 Bubble Sort algorithm.

Anyways, according to my findings, I realize that I must use Redis, queueing system, consumers and multiple threads so I can run these tasks in parallel. This will not only reduce the abuse of heap but will also utilize CPU much more effectively.

I also discovered a library that takes care of all of the above and more, called, "Kue." I'm not sure if it, by default, runs on a different thread of has out-of-the-box support for it.

Again, thanks for taking you time to read and participating in the discussion!

EDIT: Kue does support parallel processing!