CPU, I/O and Memory Bound
We can say that a computer is CPU-bound (or compute-bound) when the time for it to complete a task is correlated to the speed of the central processor. Tasks that do a lot of calculations with comparatively little data are often CPU bound.
Image resizing, Video Editing, Gaming are some examples of CPU Bound tasks.
Similar to a fast runner who can finish a 100m race faster than the slow runners, a faster CPU can run operations faster than a slower CPU.
When a computer is CPU bound, the CPU uses 90 to 100 percent of its energy rather than the 10 to 20 percent it commonly uses at other times.
In CPU-bound systems, for better performance, it is required to upgrade the CPU than upgrading other components.
Of all the bound systems such as I/O bound, Memory bound and Cache bound, CPU bound is the fastest and most used.
To increase the performance of the CPU bound the user can focus only on upgrading the CPU.
Since the CPU is the most used while performing operations the other components are left behind.
The CPU upgrade is costly.
It creates an imbalance because other components are not being used.
Another disadvantage of a CPU-bound system is, while the CPU is fast, it will only be able to work only a few processes at a given time. It means, even if the user has several programs open, only one or two will be working faster, while the others will hardly move.
A system is said to be I/O bound if the time taken to complete a computation is dependent on the period spent waiting for input/output operations to be completed. This is the complete opposite of a system being CPU bound where the tasks are determined solely on the performance of the CPU.
A task that processes data from a disk, like counting the number of lines in a file is called an I/O bound.
The I/O bound state is not considered desirable because it means that the CPU must stop running its operation while waiting for data to be loaded or unloaded from the storage. So, this makes I/O bound slower than non-I/O bounds.
Differentiate CPU and I/O Bound
The CPU scheduler assigns time slices to processes(or)threads and switches between them whenever the time slice has run out or the process/thread blocks for I/O.
An I/O-bound job will block the I/O every now and then, and a process/thread which makes use of this full-time slice will be assumed to be CPU-bound. By identifying whether a process/thread blocks at the end of the time slice, it is easy to find the types of processes.
But most of the time applications are not either I/O-bound or CPU-bound instead they switch roles all the time.
While switching between the CPU and I/O bound, the following scenario may take place if we have only one CPU bound process and multiple I/O bound processes to be executed.
Like the CPU bound process will hold CPU while the other I/O bound process finishes running their I/O and gets added in the queue to use the CPU.
At this time, the I/O devices are idle while the CPU is held by the CPU-bound process. Then the CPU-bound process moves to the I/O part leaving space for the I/O bound process to use CPU. The I/O bound processes with shorter CPU bursts get executed quickly and move to I/O again which is held by the CPU-bound process now.
Now the CPU will be left idle. And all the I/O bound processes are now in the queue waiting for the CPU bound process to leave the I/O. This effect will result in less CPU and I/O utilization and can be eliminated by allowing the shorter process first.
Memory-bound is the time taken to complete a computational task which is dependent on the amount of memory required to hold the working data.
Requests per second(RPS) is a measurement of the throughput of a system. It is an important metric of the system. The requests can be like fetching data from a database using queries or getting an URL from a website etc.
There are a few types of RPS such as CPU-bound, I/O bound and Memory bound.
When a system is CPU-bound, to process an image or to do any calculations, the CPU will be the one being utilized the most. So here the limiting part is the CPU itself. The CPU’s power will determine how many tasks can be done at a particular speed.
If the CPU has more cores, then the more advantage it is. Cores are equivalent to the workers assigned to complete a certain task.
The more the workers(cores), the faster the task gets complete and higher the Requests per second would be.
The computer fetches data from a database or reads a file from another network. When the system is memory-bound, the CPU is almost idle. Here we have to store the data in the memory before even we can start working on it. The limit here is the RAM.
The workers here are the memory. More memory means more workers we have to complete our task. The more the workers(memory), the faster the Requests per second(RPS) would be.
In an I/O bound system, the interaction takes place between computers similar to a human conversation. To talk to another computer, this computer creates a request that the other computer must receive in order to communicate with each other like humans talk and receive words with each other in a conversation.
In a UNIX-based computer, this creation of request by one computer and acceptance by the other results in a creation of a file descriptor. A computer has only a limited number of file descriptors. So, the limit here is the open files limit.
Open file limit has soft and hard limits. The soft limits affect processes and the hard limits are the maximum values of the soft limits. The default limit of soft limits is 1024 and for hard limits, it is 4096. The higher the open limits, the higher the Requests per second(RPS) can be.