WICG/scheduling-apis

Node.js

benjamingr opened this issue · 3 comments

Does a postTask API make sense for Node.js (in any way)?

I've been thinking of exploring adopting this API or experimenting with it in Node.js with the use case I've been thinking about is similar main thread contention. I have a server that serves a large number of users. That server needs to manage QoS of various levels of requests. Some requests should be very fast while for other requests I really wouldn't mind the users to wait a few milliseconds.

For example if I have a request that hashes an image and stores it for later retrieval - it might be OK for that request to wait until the CPU is idle. Work that takes more than a few milliseconds typically gets put in a (persistent) queue on servers but there is certain work I probably wouldn't mind waiting for.

The same goes for CLI tools, webpack might be interested in performing certain kinds of analysis in a lower priority than actually outputting the compiled code. TypeScript might "emit" before it's done type-checking to give users a snappier experience etc.

The main issue I see here is that Node.js already exposes threads and processes (with worker_threads and child_process) - so users already have access to the operating system scheduler. That said, it would be cool if some code could be made universal and shared here.

Hi @benjamingr, thanks for digging in here!

I agree that it would be cool if some code could be shared here, but I'm not as familiar with use codes on the Node side of things. @sebmarkbage and @acdlite who have been working with us on this might have some thoughts?

One thing to note here is that the API is still experimental and just recently entered origin trial, so things are subject to change.

One thing to note here is that the API is still experimental and just recently entered origin trial, so things are subject to change.

Thanks for the update - that is precisely why I wanted to make sure we ( Node.js ) provide feedback on it as soon as possible if it is applicable and attempt to collaborate and see if this is something we can be a consumer of.

I will also create a Node.js issue to raise the discussion there. What would be a constructive way to collaborate to figure out if this makes sense for Node.js and provide feedback?

I opened an issue in the Node.js repo to make sure this isn't missed. Thanks!