Blog Archive

I am an Oracle database Consultant My Areas of Interests being High availabilty,Infrastructure consulting and Performance Tuning. I am posting Topics of My interests Related to these Technology Areas. Do post Your comments as well.

Sunday 11 February 2007

Operating System Fundamentals

Operating System Fundamentals

System Architectures

The sizing and capacity planning of hardware at each level be it a database server or application server in a multi level environment is a challenge that most of the system architects face. It is important to achieve a balanced design. Configuring the initial system architecture is largely an iterative process. The system requirements are to be met within budget and schedule constraints.
The main hardware components that are considered while designing a system include CPU, memory, the I/O subsystem, and the network.
Based on the design, system architectures can be classified into different categories. However, the Oracle server can run on the following types of architectures:

Uniprocessor

Uniprocessor systems have only one CPU and memory.
Symmetric Multi Processor(SMP) SMP systems have multiple CPUs. The number commonly ranges from 2 to 64. All the CPUs in an SMP machine share the same memory, system bus, and I/O system. A single copy of the operating system controls all the CPUs.

Non Uniform Memory ArchitectureNUMA

Numa systems consist of several SMP systems that are interconnected to form a larger system. In contrast to a cluster, all of the memory in all of the SMP systems are connected to form a single large memory space transparent to all subsystems. A single copy of the operating system runs across all nodes.

Massively Parallel Processor MPP

MPP systems consist of several nodes that are connected . Each node has its own CPU, memory, bus, disks, and I/O system. Each node runs its own copy of the operating system. The number of nodes in an MPP system can range from two to several thousands
ClusterA cluster consists of several nodes loosely coupled using local area network (LAN)interconnection technology. Each of the individual nodes can in itself be composed of a single-processor machine or SMP machine. In a cluster, system software balances the workload among the nodes and provides for high availability.
Planning and Evaluating system Memory Requirements
To have a well performing system we need to plan so that the system has adequate memory not just for the bigger jobs,rather it should be able to handle most of the jobs for day to day use.This can be explained as lets say the total memory required for one or two bigger jobs that run for a long period of time might provide an inferior response under huge system overload due to other system activities.But a system having memory sufficient enough to support a systems normal day to day operations will result in poor performance when huge batch jobs run.Hence while planning we need to consider the above mentioned requirements, though a detailed approach might be required here.

Memory Related Issues

Memory contention occurs when processes require more memory than is available. To cope with the shortage, the system pages or swaps programs and data between memory and disks.
Swapping refers to writing an entire process to disk there by freeing up all the physical memory that it was occupying.But if the process needs to execute the process, Operating system needs to read it from the disk again.
Paging refers to wrting a section(Block) of process's memory in building blocks called pages to disk,in the process this gives or frees up physical memory region for some other process.A page fault occurs when a process needs a page of memory that is not in the physical memory region and re-read from the disk.On Virtual memory systems true swapping should never occur but if you come across on then this is a sure indication of memory bottleneck.
Operating systems make use of virtual memory, which gives the applications the feeling that they are the only application on the system. The virtual memory area is divided into memory pages. The OS maps these virtual memory pages into physical memory by the use of a Memory Management unit, the mapping between virtual and physical memory is under the control of a page table The most recently used pages are kept in real memory while the least recently used pages are in the virtual memory.Both paging and swapping require adequate disk space to temporarily hold the memory blocks on disks and are I/O intensive.
If system is swapping and you must conserve memory, then:
Avoid running unnecessary system daemon processes or application processes Decrease the number of database buffers to free some memory Decrease the number of file buffers (if using UNIX)
Oracle recommends to set the swap space to between two and four times the system's physical memory. Monitor the use of swap space and increase it as required.
Usefull commands Linux :swapon -s to get the swap space details swapon -a to add more swap space
Control PagingPaging might not present as serious a problem as swapping,in fact paging is what causes the virtual memory possible there by allowing a process's memory requirements to greatly exceed the actual amount of physical memory.
Paging will cause problems when there is very small amount of physical memory for all the processes currently running on the system.If such a case occurs the Operating system will divide the total memory among all the processes dynamically.When a process needs to read a new page and system finds that there is not enough free or reusable space , then the only way it can give room to the new page is freeing up pages used by some other process which results in a page out writing out in a paging area on the disk.But this page might be required soon causing another pagout.This means that huge amount of cpu time is spent on handling page faults,and results in less process execution and hence slows it down.When the Race condition is approached the system will be managing only virtual memory and no process execution is going on ie no CPU cycles are actually used to advance the execution of the process.Note that under there circumstances you may be mislead by a low cpu usage !!!
Use the vmstat or sar commands to monitor paging.
If you find excessive page-out activity, thenInstall more memory. Move some of the work to another system. Configure your kernel to use less memory.
It is recommended that the total combined size of the page files be at least the same size as the physical amount of RAM on the computer. A higher value of the same is suggested by oracle if you plan to use Oracle development tools or Oracle Applications. Monitor the use of paging space and increase it as necessary. Although the goal is to minimize paging as much as possible, a situation in which the operating system runs out of or is low on paging space should be avoided at all costs.
You can cause Oracle to read the entire SGA into memory when you start your instance, by setting the LOCK_SGA initialization parameter to TRUE.This should be used only on systems that have sufficient memory to hold all the SGA pages without degrading performance in other areas.

Disk I/O Tuning

System Calls for I/O
Operating systems can perform disk I/O in two different ways:
Normal I/O System Call
Any process say in case of Oracle DBWR issues an I/O requestusing a normal I/O system call to the operating system , the process has to wait until the I/O completes before issuing the next I/O request. Thus using this mode there is a imit on the amount of I/O any process can perform in a specific amount of time.
Asynchronous I/O System Call
If a process issues an I/O request using an asynchronous I/O system call,the process can continue the current processing and does not have to wait until the I/O operation completes.Once the the operation is completed the operating system notifies the process that I/O has been completed. By using asynchronous I/O processes can overlap multipe I/O requests.
Implications of Async I/O on Oracle File systemsAlmost all the unix systems support async I/O on file systems t is usually implemented with user-level multithreadingcapabilities in the operating system. This is implemented as a threading model where a thread is created to handle each I/O request. Whenever an I/O request is made, a thread is spawned to service the incoming request and control returns to the main thread. But the child thread does this through a normal I/O on the request, but another thread can be processed at the same time. The parent thread checks for I/O completion.The resources are to be allocated for each thread and the context switching among the threads make this approach less scalable.Therefore, it induces a significant CPU overhead for database file systems. To avoid this CPU overhead, use multiple database writers or database writer I/O slaves rather than asynchronous I/O.

Raw Devices and Async I/O

Asynchronous I/O on raw devices is implemented in the OS by using kernel threads, which has minimal CPU overhead. An additional benefit is that the data is not buffered in the operating system cache although this has been eliminated by uisng Direct I/O and Quick I/O file systems. This reduces memory requirements and there is no need to make the OS execute code to manage the file system cache or map file system blocks to physical disk blocks.The Oracle Implementaion of Automatic Storage Manager in 10g supports KAIO But note that Direct I/O does not support KAIO.

For more details
http://www.ixora.com.au/notes/raw_asynchronous_io.htm

http://www.ixora.com.au/tips/creation/sequential_reads.htm

1 comment:

derek said...

Sriram,

I received a notice of your article on capacity planning from my Google alerts. Capacity planning is no longer as difficult as you maintain, as a few companies have automated the complex calculations required for multi-tier, multi-system capacity planning. My company, HyPerformix, has automated tools for capacity planning that evolve the effort from an iterative one to an automated one. In fact, this is not new technology, as several CMG white papers have been written on the subject and our software is used by over 30% of the Fortune 100. You should check out our website.

Cheers,

Derek
VP Product Management
HyPerformix

p.s., Doug yoou know Virag Saksena? He used to work at Oracle in the database performance area.