When to use Node JS

Working of Node JS

  • Node JS works on single thread
    • So suppose you run a loop for like 100 million times, so single thread of node has to perform that which makes it processor intensive which is not a area where Node JS shines.
  • Node JS Works asynchronously and it is non blocking
    • As we know Node JS is single threaded so it does not wait for an I/O or network to return a response, instead it creates a callback which handles the response. When the response is received.

Node is good at following work :

  • Non-Blocking
    • After making an api call, it does not wait for the response of that API, instead it writes a call back which handles the event of getting data from API and puts it list of events that it has to execute one by one.
  • Event-Driven
    • Waits for a event to happen and executes the event
  • Data-intensive
    • When lots of data has to be handled but not processed (Lots of API call to be made)
  • I/O intensive
    • Waiting for lots of Input and Output devices together

Node is not good for follow work :

  • Data Calculation of large amount
  • Processor Intensive
  • Blocking Operations

Example Applications :

  • WebServers
    • Because of event driven model
  • APIs fronting NO SQL DB
  • Command Line utilities
  • Build Tooling (Like building angular application)

Leave a Comment