3 4
Now that we have sized and analyzed the memory, it's time to do the same for the processor. At this point, we can make the following assumptions about the system:
We've made use of these assumptions as guidelines and thresholds for sizing memory, but for anticipating capacity for the CPU, we need additional information. This information can be provided by the database designer and the application designer.
Anticipating the capacity of a CPU on a database server is not as complicated as you might think. Remember that a database server is only processing transactions. The application is running on a client machine, so application sizing does not enter into the equation. The server will be processing requests from users in the form of read and write operations—that is, it will be processing I/Os. The application designer can provide pertinent information about the nature of the transactions. The database designer can provide information pertaining to the tables and their indexes that will be affected by these transactions. So the task at hand will be to determine how many I/Os will be generated by the transactions and in what time frame they have to be completed. We need to know how many transactions the system will be required to process and the definition of either the working day in terms of hours for this system or the peak utilization period.
As we've seen, it's always preferable to size for the peak utilization period because it represents the worst-case scenario and we can build the machine to accommodate it. Unfortunately, in most cases this information will not be available, so we are forced to use the information we have pertaining to steady state. To gain a deeper understanding of the transactions that we will be processing, we need access to the transaction anatomy, or profile, which will help us determine the numbers of reads and writes (I/Os) that will be generated and enable us to calculate the anticipated CPU utilization. We get this information from our interview with the database designers and the application designers. First we need to know how many transactions of each type will go through the system, and then we need to determine the number of I/Os that will be generated. This calculation will provide an estimate of the CPU workload.
For an existing system, the user can profile transactions by running each of the transactions one at a time and tracking them using Performance Monitor to determine the number of I/Os generated. This "real" information can be used to adjust the speed, type, and number of CPUs in use.
So far, we have talked about sizing the CPU in terms of I/Os generated by user transactions. I/Os can also be generated by the fault tolerance equipment that may be in use. These additional I/Os must also be considered when you are sizing the CPU.
Most computer companies today provide fault tolerance through the support of RAID (Redundant Array of Inexpensive Disks) technology. (See Chapter 5 for an in-depth description of RAID technology.) Remember that the most commonly used RAID levels are as follows:
Because RAID 0 requires a single disk, it has a single point of failure—in other words, if the disk drive fails, you will lose the data on that disk drive and therefore the entire database. A RAID 0 array is shown in Figure 4-1. RAID 1 provides a mirror image of the database disk drive. If a disk drive fails, you have a backup data drive complete with all the data that was on the failed disk drive. If you specify RAID 1, users get the added benefit of split seeks (covered in Chapter 5), which enable the system to search both drives simultaneously, greatly accelerating search speed and thereby reducing your transaction response time. A RAID 1 array is shown in Figure 4-2.
The choice of RAID level directly affects the number of disk I/Os because different RAID levels alter the number of writes to the disk. For example, RAID 1 requires twice as many writes as RAID 0. If the user describes a transaction as having 50 reads and 10 writes and wants to use RAID 1, the number of writes increases to 20.
If a RAID 0 configuration has two designated disk drives, a comparable RAID 5 configuration would have three disk drives. In a RAID 5 configuration, a parity stripe is used that contains information about the data on the other two drives that can be used to rebuild a failed disk's data. A RAID 5 array is shown in Figure 4-4. This database protection scheme comes with a performance cost as well as a dollar cost. Each write under RAID 5 will add twice the number of reads and twice the number of writes for each transaction processed because each transaction must be written to two disks, and the parity stripe must be read, altered to incorporate the new data, and then written. This redundancy will lengthen the transaction response time slightly.
To calculate the number of I/Os for the various RAID levels, you can use the following equations.
For RAID 0:
number of I/Os = (number of reads per transaction) + (number of writes per transaction)
If a transaction has 50 reads and 10 writes, the total number of I/Os using RAID 0 is 60.
For RAID 1:
number of I/Os = (number of reads per transaction) + (2 * (number of writes per transaction))
If a transaction has 50 reads and 10 writes, the total number of I/Os using RAID 1 is 70.
For RAID 5:
number of I/Os = 3 * (number of I/Os per transaction)
If a transaction has 50 reads and 10 writes, the total number of reads would be 150 and the total number of writes would be 30. The total number of I/Os using RAID 5 is therefore 180.
The increase of I/Os is a function of the disk controller and is transparent to the user, who does not need to make adjustments to the application. Remember that your RAID selection directly affects the number of I/Os that will be processed. This increase of reads and writes should be considered, as it will affect the utilization factors of the CPUs and the quantity of disks chosen during sizing.
Once you have calculated the total number of reads and writes due to user transactions and added the additional I/Os due to the RAID levels you have selected, you have all the information you need to calculate the CPU utilization. The following formula is used to determine the CPU utilization of a proposed system:
CPU utilization = (throughput) * (service time) * 100
Here throughput is the number of I/Os to be processed per second, and service time is the amount of time spent processing a typical I/O transaction. This formula simply states that utilization is the total number of I/Os the system processes per second multiplied by the time it takes to perform each task, multiplied by 100 to get a percentage.
To determine the number of CPUs needed for the system, the following steps should be performed on every transaction that will be processed as part of this workload.
total reads = (reads per transaction) * (total number of transactions)
total logical reads = (total reads) * (cache hit rate) total physical reads = (total reads) - (total logical reads)
logical reads/sec = (total logical reads) / (work period) physical reads/sec = (total physical reads) / (work period)
The work period should be the length of time, in seconds, in which the work is to be performed.
logical read time = (logical reads/sec) * (logical read time) physical read time = (physical reads/sec) * (physical read time)
The logical read time is the time it takes to process a logical read. The physical read time is the time it takes to process a physical read. These read times can be obtained using Performance Monitor. (See the sidebar "Obtaining Read Times" at the end of this list for directions.)
NOTE
Typical values for read times are 0.002 second for the physical read time variable and 0.001 second for the logical read time variable.
utilization = (throughput) * (service time) * 100
You can break this down into logical and physical read utilization as follows:
logical read utilization = (logical reads/sec) * (logical read time) physical read utilization = (physical reads/sec) * (physical read time)
This information can be used to determine whether there is too much physical read utilization. You can then adjust the cache size so that you will have more logical reads.
total writes = (writes per transaction) * (total number transactions) * (RAID factor increase)
writes/sec = (total writes) / (work period)
Again, the work period should be the length of time, in seconds, in which the work is to be performed.
CPU write time = (writes/sec) * (CPU write time)
write utilization = (writes/sec) * (CPU write time) * 100
CPU utilization = ((logical read utilization) + (physical read utilization) + (write utilization)) * 100
This calculation must be performed for each type of transaction that your system allows. For example, if you have a banking system, you might allow withdrawals, deposits, and balance inquiries. You must perform these utilization calculations separately for each of these three types of transactions to accurately size the CPUs for your system.
total CPU utilization = sum of all transaction utilizations
If the total CPU utilization is over the 75 percent threshold, you should add more CPUs to your system. Additional CPUs will reduce the total CPU utilization according to the following formula:
total CPU utilization (>1 CPU) = (total CPU utilization) / (number of CPUs)
Add enough CPUs to bring the total CPU utilization below 75 percent. For example, if total CPU utilization is 180 percent, you would use three CPUs. The resulting total CPU utilization would then be 60 percent for the three-CPU system.
NOTE
You might be wondering why we have not used processor speed in any of our calculations. In fact, we have—indirectly. Processor speed is accounted for in the service time—the amount of time spent processing a transaction.
You can obtain the read times for your system through Performance Monitor. Turn on Diskperf by entering the following command in an MS-DOS window:
diskperf -y
Next start Performance Monitor, and look in the Physical Disk object for the Avg. Disk sec/Read and Avg. Disk sec/Write counters. Note that these counters give you the average read times for physical reads. Don't worry about these times for logical reads.
When your system is implemented, you will need to track CPU usage much as you tracked memory usage. Performance Monitor contains many counters related to individual CPU usage. These counters are contained in the Processor object. The following counters will be the most useful for sizing purposes:
Not all of these counters are required to conduct a capacity planning study—the counters you select will be determined by the depth of the study you are conducting. At the very least, the % Processor Time counter should be used.
You can also retrieve system-averaged data for multiple CPUs via Performance Monitor. Use the System object, which includes the following counters, among others:
The data you obtain using these counters can be used to predict rises in a specific CPU's utilization and therefore increased response times from that CPU. Figure 66 shows CPU utilization over time. Notice that the utilization trend for the CPU is rising; it will reach the 75 percent threshold by February 18, 2000.
Figure 6-6. Linear CPU utilization predictive analysis.
NOTE
The more data points you collect, the more accurate your prediction.