[Node.js] Single-threaded Event Loop
1) A simple analogy What is single-threaded event loop? Hope the following analogy of a doctor visit will help you! For this analogy, we are doing comparison in context of server-side web architectures. In a traditional thread-model, when you get to a receptionist, you stand and fill out your form for as long as it takes. While you are filling out your form, the receptionist just sits and wait for you; unable to serve other people behind you. The only way to scale is to add more receptionists, which is costly - both in terms of labor cost and room allocation for the receptionist to sit. In an event-based system (which is what single-threaded event loop relies on), when you get to the receptionist, you are given a form to fill and told to come back after you have completed it. You sit down and fill the form as the receptionist helps the next period in line. You are not blocking the receptionist from serving the next person. When you are done, you line up again and h