HOME   SEARCH   CONTACTS 
SSL Powered by WebGUI

Articles on Software Development and Computer Related Topics


Site Menu



 

Partition Alignment for Optimal Database Performance

Following layout is recommended: partitions contain only whole stripes, those consist of only whole clusters (or file blocks).
Very important: Partition Offset = integer_number*hw_chunk_size
Optimal: hw_chunk_size=integer_number*CS 
hw_sector_size = 512 bytes
hw_stripe_size = hw_chunk_size = Stripe Element Size (specified in RAID) = Stripe Unit Size = RAID Block Size = the "atomic" mass of data that is written to the devices
hw_stripe_width = Number_of_non_mirroring_disks (or data bearing disks)
cluster_size = Ext3 block size = File Allocation Unit Size
ext3-stride = hw_chunk_size / cluster_size =number of clusters writen sequentially to a single disk; So the Stride_Sise (step) should be the number of cluster_size in the Stripe_Element_Size
ext3-stripe-width = hw_chunk_size * hw_stripe_width = ext3-stride * cluster_size * hw-stripe-width

Usefull options:
 Ext3: -O dir_index -O sparse_super
 RAID: "write back" should be disabled

Optimal sizes: hw_chunk_size=cluster_size
 OLTP (more writes): 64-128 кБ
 OLAP (more reads): 128-256 кБ

Example:

RAID 10 built from 4 disks, hw_chunk_size=1Mbyte, hw_stripe_width=2

Now use attached PartitionAlignment.xls for partition layout calculation.

root@sysresccd /root % fdisk -u /dev/sda

The number of cylinders for this disk is set to 35564.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
  (e.g., DOS FDISK, OS/2 FDISK)

Command (m for help): p

Disk /dev/sda: 292.5 GB, 292527538176 bytes
255 heads, 63 sectors/track, 35564 cylinders, total 571342848 sectors
Units = sectors of 1 * 512 = 512 bytes
Disk identifier: 0x0008e493

  Device Boot Start End Blocks Id System
/dev/sda1 2048 2099199 1048576 6 FAT16
Partition 1 does not end on cylinder boundary.
/dev/sda2 2099200 10487807 4194304 82 Linux swap / Solaris
Partition 2 does not end on cylinder boundary.
/dev/sda3 10487808 94373887 41943040 83 Linux
/dev/sda4 94373888 571342847 238484480 83 Linux

Create filesystems (format):
ext3-stride=hw_chunk_size/cluster_size=1MByte/ 4(Kb/Cluster)=256 clusters
ext3-stride-width = 1Gb/4Kb = 256; ext3-stripe-size = 256 * 2 = 512
# mkfs.ext3 -E stride=256 -E stripe-width=512 /dev/sda4

[db2inst@old_db2_host data]$ date; dd if=/dev/zero of=./swap2 bs=1048576 count=10000; date
Thu Jun 4 12:49:24 YEKST 2009
10000+0 records in
10000+0 records out
Thu Jun 4 12:55:36 YEKST 2009

root@sysresccd /mnt/d2 % date; dd if=/dev/zero of=./swap2 bs=1048576 count=10000; date
Thu Jun 4 06:14:02 UTC 2009
10000+0 records in
10000+0 records out
10485760000 bytes (10 GB) copied, 63.3384 s, 166 MB/s
Thu Jun 4 06:15:09 UTC 2009

Results: 
New disk array is 6 times faster for writting large chunks of data