N
Nuxt10mo ago
bnason

Server side worker thread

Is it possible/safe to create a server side worker thread for a long running up intensive task? If multiple of these tasks run, it slows down the responsiveness of the web interface. Hopefully moving them to their own threads should resolve that
8 Replies
akaSECTION
akaSECTION10mo ago
up Also, I have similar case, not for intensive task, but rather a background job. Is there a way to build a worker JS file on server-side and reference them so we can spawn the worker?
Unknown User
Unknown User10mo ago
Message Not Public
Sign In & Join Server To View
bnason
bnason10mo ago
Well I'm running 100,000s of small worker jobs that are using a lot of cpu so my process starts to slow down responding to web requests. if I can run them on a second cpu, my main web response should get better. I know there is a node feature called worker threads, but that I believe just launches a single file as a new thread basically. So that code wouldn't have access to anything in Nuxt. I wish there were a way to add cli commands to nuxt, that way the worker could boot up with everything availble to Nuxt
akaSECTION
akaSECTION10mo ago
hmm in your case, isn't that better to entirely separate the worker process into different pid? then bridge both of them via IPC?
bnason
bnason10mo ago
I guess the hard part here is having the worker have access to stuff that gets setup in nuxt, IE db, redis connections etc. At least without re-implementing that outside Nuxt
Unknown User
Unknown User10mo ago
Message Not Public
Sign In & Join Server To View
bnason
bnason5mo ago
@brian7ng Just checking up on this. Are you a developer for Nuxt? Should I create a GitHub issue for this? I'm coming back to trying to resolve this in my project and really need to figure out a solution.
bnason
bnason5mo ago
GitHub
Server side threads · nuxt nuxt · Discussion #25870
I'm looking for a way to create a server side thread. I have a BullMQ queue setup that processes hundreds of thousands of jobs and it causes the server to respond slowly when its working. The m...