Posts

Showing posts from May, 2021

event loop and callback queue ,call stack

https://medium.com/@Rahulx1/understanding-event-loop-call-stack-event-job-queue-in-javascript-63dcd2c71ecd   call stack Javascript is single threaded asynchronous language . Using asynchronous JavaScript (such as callbacks, promises, and async /await), you can perform long network requests without blocking the main thread.     Event loop  Event loop is an endless loop, which waits for tasks, executes them and then sleeps until it receives more tasks. It  allows node js to perform non-blocking I/O operations.   Explain asynchronous and non-blocking APIs in Node.js. All Node.js library APIs are asynchronous, which means they are also non-blocking A Node.js-based server never waits for an API to return data. Instead, it moves to the next API after calling it, and a notification mechanism from a Node.js event responds to the server for the previous API call      
 What is Node js https://www.monterail.com/blog/nodejs-development-enterprises https://medium.com/@abshirj05/what-does-event-driven-and-non-blocking-i-o-mean-57ac4f54288e Event driven means when you make a ca l l, your node server catches the request and registers a function. Let me repeat, Nodejs registers a function instead of the actual data. Why though? Here is why. Instead of having the event-cycle to wait for the data while it’s fetching (which could take sometime), node simply registers an event that will be called when the fetching is done and frees the event-cycle to take the next request.   How node js works? https://www.youtube.com/watch?v=YSyFSnisip0&t=463s  Note-: use node js for i/o intensive not for CPU intensive . node js uses non blocking i/o and event loop  . event loop makes node js asynchronous . node js libuv which is written in c++ and c++ uses system kernel so behind the scene multithreading is done.   single thread accept reques...