Concurrent I/O is a function introduced in UNIX and Linux platforms and is mainly used in relational database systems. This article describes the differences between IO mechanisms that can be used in UNIXLinux file systems, and how to use concurrent I/O technology in the IBMDB2 environment to improve database performance.
Concurrent I/O is a function introduced in UNIX and Linux platforms and is mainly used in relational database systems. This article describes the differences between I/O mechanisms that can be used in UNIX/Linux file systems, and how to use concurrent I/O Technology to Improve database performance in the IBM DB2 environment.
Concurrent I/O and cache I/O are two functions associated with the file system. For this reason, most DB2 DBAs believe that the use of these two technologies depends on the knowledge of storage and system administrators. However, it is DBA's responsibility to use this technology in the DB2 environment. In fact, IBM DB2 experts recommend implementing this technology at the level, because it enables DB2 Database Manager to control which files should be opened and which files should not be opened using the O_CIO mark.
This article introduces the concept of concurrency and cache I/O, and focuses on the important differences between the two. More importantly, it will introduce how to improve CPU and memory utilization by using concurrent I/O technology in the DB2 database environment.
The main topics described in this article are as follows:
- Cache I/O and its impact on DB2: How the cache I/O works when an application sends a request to the operating system, and how this affects relational DBMS such as DB2.
- Concurrent I/O (CIO) and its relationship with DB2: the working principle of concurrent I/O, the difference between direct I/O and concurrent I/O, the performance similarity between CIOs and original devices, and the benefits of these performance on DB2.
- How to Implement CIOs: the implementation aspects related to DB2, the simplicity of the implementation, and the appropriate time to use it.
- CIO (restrictions and limitations): the CIO cannot or should not be used.
- Various applications that can benefit from CIOs, as well as examples of use in the real world.
What is cache I/O?
When an application sends a request to access the data in the disk, the operating system can process the request in two ways: one is to directly retrieve the data from the disk, the other is to use a cache area to reserve frequently accessed data for quick access. The execution of physical I/O for each request affects the performance, and the data retrieval process can be improved by having a buffer in the memory that caches frequently accessed data.
The purpose of the file buffer cache is to minimize the frequency of physical disk I/O by placing frequently accessed data in the main memory. As a result, when the cache hit rate is very high, the use of the file buffer cache can effectively reduce disk I/O. This data retrieval method is often called cache I/O. When an application sends a read request to the operating system, the operating system first searches for the required data in the file buffer cache. If the data is found here, it will be obtained from the cache and written to the application buffer, without entering the disk. However, if the requested data is not in the file system cache, the operating system must obtain the data from the disk and store it in the file system cache, then it is transmitted to the application buffer.
Figure 1 shows how to use the I/O cache for data read operations.
- The application sends a read request.
- The operating system looks for the requested data in the file buffer.
- The requested data is not in the file buffer cache.
- The operating system reads data from the disk.
- The read data is cached in the file buffer cache.
- The read data is copied from the file buffer cache to the application cache.
Figure 1. How to Use the I/O cache for data read Operations
Another advantage of caching I/O is that the operating system can use asynchronous file writing. In other words, the application can continue without waiting for a write operation to complete. Like reading, cache I/O tries to cache the data to be written in the file system buffer to improve future Data Reading and minimize write operations to the disk. Therefore, for read and write requests, cache I/O supports read first and write later, which helps improve performance when the cache hit rate is very high.
Figure 2 shows the following steps to use the I/O cache for Data Writing.
- The application sends a write request.
- The operating system copies data from the application buffer to the file buffer cache.
- The application continues to run without waiting for the disk to be written.
- The synchronization daemon regularly refreshes the cache page of the dirty File Buffer.
- Write dirty pages to the disk.
Figure 2. How the I/O cache is used for data write operations
Although data caching is suitable for most applications, it is redundant and is often unnecessary for most DB2 databases. This is because DB2 has its own cache region (in the form of one or more buffer pools) and DB2 uses this cache region to store accessed data for most of its operations. In addition to the DB2 buffer pool, the usage of the file system cache actually increases the CPU and memory overhead. A large part of the system memory is often used in the file buffer cache. Copying data to the file system cache or copying data from the file system cache to the buffer pool consumes more CPU resources.
For write requests with cache I/O, the operating system uses the so-called Inode locking mechanism to execute write serialization to maintain data integrity. As a result, when I/O is used in DB2, another kind of overhead is introduced, because DB2 maintains data consistency and integrity through its own locking mechanism.