Hi you probably heard about non-blocking i/o technology, or maybe not?
To maintain product quality, we implemented many procedures, some of them explained in the startup execution process video where we implement minimum code quality, and in this article, we will explain other procedures we use in order to maintain product quality by optimizing CPU usage of a process by using non-blocking i/o technology.
Blocked Technology
let’s have a brief explanation what is blocked technology, so we understand what is the benefit by using non-blocked technology.
Imagine in a cafe where it has waiters, when customer come a waiter serve to take an order for that customer and only leave once the order has been made by the customer, so during customer went through the menu the waiter will wait patiently until the customer ready to make an order.
This is what we call blocked technology by waiters only serving 1 customer to make order until the order has been made, then the waiter will pick up another customer. In analogy, we can assume the waiter is a CPU and is only actively used when it offers a menu and receive the order, the idle time consumed by a waiter while waiting for the customer to go through the menu and think about it is normally an i/o process in the backend process, it can be database network call or API call to other services.
Non-Blocked Technology
With non-blocked technology, those idle time will be used by the waiter to serve other customers in case,
Other custome want to receive a menu or are ready to make an order, so there’s no idle time for the waiter at all; in this analogy related with the CPU, once it comes to idle time related with I/O network it can serve other request and will back once current process is done with I/O call
this will make CPU usage more efficient and will be better on handling a large number of requests like capturing events for analytics.
When to use blocked and non blocked technology
Use non-blocked technology when the operation process is mainly CRUD or integration with third party services, where majority of the process is I/O process. and use blocked technology when it requires heavy logic and calculation like machine learning process or image processing.