Christa
Christa

Reputation: 61

Using Node Clusters vs Redis Bull background processes for improving slow endpoint performance

Looking to improve performance for a slow endpoint that is blocking the event loop. Using a Postgres database hosted with Heroku.

Heroku's docs recommend implementing background jobs with Redis to improve performance. This seems like it would require paying for and setting up Redis on top of our current Postgres database, as well as setting up Bull for the worker processes themselves.

https://devcenter.heroku.com/articles/node-redis-workers

This commenter brought up using Nose.js clusters as a possible solution.

Using worker/background processes in node.js vs async call

We're not currently using Redis, if there's a simpler (and cheaper) solution I would rather implement that. Would using Node worker threads accomplish the same thing as setting up Redis with Bull? A significant portion of computing time is spent on this endpoint and we've already made efforts to make improvements through indexing and restructuring.

Upvotes: 0

Views: 994

Answers (1)

VitoMakarevich
VitoMakarevich

Reputation: 455

Looks like Redis have significant plus: it will cache data and any kind of errors/deployments/etc. will not prevent to losing data, which you can't do with node.js workers, to accomplish same you need to use something like RabbitMQ to store your jobs. If you have time and resources for reimplement Redis or this is the edge case for you - try to use workers, otherwise some 3rd party tool will do it for you without headache why you've some data inconsistency. Also you can not use workers and create single-thread app and spawn it many times automatically using kubernetes

Upvotes: 1

Related Questions