3 months ago
I had setup a Nestjs api application and connect to a MongoDB Atlas service and internal Redis service on railway.
I toggle the "Serverless" option for my api service but seem there still up all the time and when i connect to the api, it response so quick
I wonder if the serverless is useless or because my BullMQ keep calling for Redis so it cannot sleep ?
2 Replies
3 months ago
Yep that is totally correct. Despite selecting serverliss BullMQ is polling and keeping the service awake. BullMQ maintains persistent connections and polling mechanisms with Redis that prevent your application from going idle. Even if there are no jobs to process, BullMQ workers typically:
Poll Redis for new jobs at regular intervals
Maintain connection pools to Redis
Run background processes for job cleanup and maintenance
This constant activity means your NestJS application never truly goes idle, so Railway's serverless feature can't put it to sleep.
3 months ago
Yea, it's because of BullMQ.
Move your BullMQ worker to a separate always-on service, and keep your API serverless. Or just add an env check like if (ENABLE_WORKERS === 'true')
before starting the worker so you can control it per env.