Date.now()
async someDBIO()
const after = Date.now()-before
Ideally the after time would give you the time it spent in DB and if you do same thing when the request is received and the request is completed you get the same time, if I am not wrong.
The question is, if simultaneously somewhere else in code if I am doing CPU intensive task, then in a large number of RPS where a lot of such calls are sent to DB
because the main thread is not free enough to go back to get the get the callback data
The after time would be more than the actual time it took to do the DB operation, wouldn't it?
basically you are saying what if concurrency comes into play, right?
Yes when doing the after calculation.
This is a node event loop question. The callback queue has a max number of items that can be queued before it processes IO callbacks
Обсуждают сегодня