Sync vs Async | Ronak Malani

Post

editor-img
Ronak Malani
Feb 24, 2023

Sync vs Async

Node architecture is purely related to these two concept.

1. Sync

2. Async

Sync

imagine you went to the resturant and the waiter came and took the order from you and give order to the cheid to prepare the meal right! meanwhile chief is preparing the meal the waiter can take the orders from customer but it’s not doing it and waiting to first prepare for your meal it’ll serve you and then it’ll go next customer,

HUFF it might seem fluffy but this is what synchronous programming is where if we’ve got user request and that request has to take some time to completed and has query to operate on database meanhwile operating it can do other task but it decided to wait and this why we avoid synchronous programming.

Async

Asynchronous is on which node applications built on, in same restaurants example wouldn't it cool if the waiter can take more orders while the chief is preparing the meal for one customer, and yeah this is what Asynchronous programming is all about it allows us our thread us to handle another request while node performing the task on the one request,

and when that request got complete it’ll put that in the event queue.