Optimize Oracle On VMware (Sep 2011)

43
© 2010 Quest Software, Inc. ALL RIGHTS RESERVED. Optimize Oracle on VMware Tips for Optimal Virtualized Oracle Databases Bert Scalzo and Guy Harrison

Transcript of Optimize Oracle On VMware (Sep 2011)

Page 1: Optimize Oracle On VMware (Sep 2011)

© 2010 Quest Software, Inc. ALL RIGHTS RESERVED.

Optimize Oracle on VMware

Tips for Optimal Virtualized Oracle Databases

Bert Scalzo and Guy Harrison

Page 2: Optimize Oracle On VMware (Sep 2011)

2

Bert Scalzo …Database Expert & Product Architect for Quest Software

Oracle Background:• Worked with Oracle databases for over two decades (starting with version 4)• Work history includes time at both “Oracle Education” and “Oracle Consulting”

Academic Background:• Several Oracle Masters certifications• BS, MS and PhD in Computer Science• MBA (general business)• Several insurance industry designations

Key Interests:• Data Modeling• Database Benchmarking• Database Tuning & Optimization• "Star Schema" Data Warehouses• Oracle on Linux – and specifically: RAC on Linux

Articles for:• Oracle’s Technology Network (OTN)• Oracle Magazine,• Oracle Informant• PC Week (eWeek)

Articles for:• Dell Power Solutions

Magazine• The Linux Journal• www.linux.com• www.orafaq.com

Page 3: Optimize Oracle On VMware (Sep 2011)

3

Books by Bert …

Coming in 2009 …

Page 4: Optimize Oracle On VMware (Sep 2011)

Guy vs. Bert

• Similarities– Also a Quest professional (Director

of R&D, creator of Spotlight, etc)– Also a Prentice Hall author (Oracle

Performance Survival Guide and others)

– Also many (20+) years experience in Oracle

• Dissimilarities– Less experienced (no Oracle 4

experience!)– Australian accent – Lack’s Bert’s Texas charm

Page 5: Optimize Oracle On VMware (Sep 2011)

Couple of Questions…

• How many people are doing Oracle on– VMware Workstation only– VMware ESX or ESXi – Other Virtual Platforms

– Oracle VM– Other Xen Server– Hyper-V– OS-specific Hypervisor (Sun, AIX )

– How many Toad users?

Page 6: Optimize Oracle On VMware (Sep 2011)

Agenda• Motivations for Virtualization

• VMware ESX resource management:

– Memory

– CPU

– IO

• Optimization tips and techniques

Page 7: Optimize Oracle On VMware (Sep 2011)

Motivations for Virtualization

Page 8: Optimize Oracle On VMware (Sep 2011)

Resistance to Database virtualization

Page 9: Optimize Oracle On VMware (Sep 2011)

Fundamental ChallengeUnderstanding the impact of resource sharing

CPUMulti-Core Processors

NetworkShared Connectivity

Load Balancing

Redundancy

MemorySharing

Over-commitment

DiskShared storage

Fiber, iSCSI, NAS

Core 4 Resources

Page 10: Optimize Oracle On VMware (Sep 2011)

Configuring VM memory

Relative Memory Allocation for this VMMinimum Memory for this VM

VM Competes for memory in this range

Maximum memory for the VM (dynamic)

Page 11: Optimize Oracle On VMware (Sep 2011)

Monitoring VM memory

Page 12: Optimize Oracle On VMware (Sep 2011)

ESX Swap

ESX virtual memory

ESX physical memory

VM VM virtual memory

ESX swap

Effective VM physical memory

ESX and VM memory

Page 13: Optimize Oracle On VMware (Sep 2011)

ESX Swap

ESX virtual memory

ESX physical memory

VM

Apparent VM physical memory

ESX swap

Effective VM physical memory

Vmmemctl

“balloon”

VM SwapVM Swap

ESX Ballooning

Page 14: Optimize Oracle On VMware (Sep 2011)

ESX Ballooning• As memory grows, ESX balloon driver (vmmemctl) forces VM to page

out memory to VM swapfile

Page 15: Optimize Oracle On VMware (Sep 2011)

ESX Ballooning

• Inside the VM, paging to the swapfile is observed.

• The guest OS will determine which pages are paged out

• If LOCK_SGA=TRUE, then the SGA should not be paged.

Page 16: Optimize Oracle On VMware (Sep 2011)

ESX Swap

ESX virtual memory

ESX physical memory

VM Apparent VM physical memory

ESX swap

Effective VM physical memory

ESX Swapping

Page 17: Optimize Oracle On VMware (Sep 2011)

ESX Swapping

• ESX swaps out VM memory to ESX swapfile

Page 18: Optimize Oracle On VMware (Sep 2011)

ESX Swapping

• Within the VM, swapping cannot be detected.

• ESX will determine which memory pages go to disk

• Occurs when VMware tools are not installed

• Even if LOCK_SGA=TRUE, SGA memory might be on disk

Page 19: Optimize Oracle On VMware (Sep 2011)

Avoiding Ballooning and swapping

• memory reservations help avoid ballooning or ESX swapping

Page 20: Optimize Oracle On VMware (Sep 2011)

VMware memory recommendations

• Paging or swapping of PGA or SGA is almost always a Very Bad ThingTM.

• Use memory reservations to avoid swapping• Install VMware tools to avoid “invisible” swapping• Set Memory reservation = PGA+SGA+process Overhead• Be realistic about memory requirements:

– In physical machines, we are used to using all available memory– In VM, use only the memory you need, freeing up memory for other

VMs– Oracle advisories (or Spotlight) can show you how much memory is

needed– Reduce VM reservation and Oracle memory targets in tandem to

release memory

Page 21: Optimize Oracle On VMware (Sep 2011)
Page 22: Optimize Oracle On VMware (Sep 2011)

VMware CPU management

• If more virtual CPUs than ESX CPUs, then VCPUs must sometimes wait.

• Time “stops” inside the VM when this occurs (for multi-CPU VMs, it’s all or nothing).

• A VCPU can be in one of three states:– Associated with an ESX CPU but idle– Associated with an ESX CPU and executing instructions– Waiting for ESX CPU to become available

• Shares and reservations determine which VM wins access to the ESX CPUs

Page 23: Optimize Oracle On VMware (Sep 2011)

Configuring VM CPU

VMs compete for CPU in this range

Shares determine relative CPU allocated when competing

Page 24: Optimize Oracle On VMware (Sep 2011)

• “CPU Ready” is the amount of time VM spends waiting on ESX for CPU

• Inside the VM, CPU stats can be misleading

CPU utilization VM

Page 25: Optimize Oracle On VMware (Sep 2011)

Spotlight Virtual CPU monitoring

Page 26: Optimize Oracle On VMware (Sep 2011)

VM CPU Overhead

• CPU intensive workloads can show significant degradation even without contention from other VMs

Physical machine was dual core 1.8GHz. ESX Server was dual core 3.5 GHz with single 2 CPU VM

Page 27: Optimize Oracle On VMware (Sep 2011)

CPU intensive workloads

• Latch contention may be exacerbated.

Disclaimer: Quick and simple workload measurements, not benchmarks; no disk activity; no para-virutualization: Your mileage will vary.

Page 28: Optimize Oracle On VMware (Sep 2011)

VM CPU Overhead

VM had exclusive access to the ESX server – no “ready” waits.

No “spare” ESX CPU to carry ESX overhead

Page 29: Optimize Oracle On VMware (Sep 2011)

VMware CPU Summary

• Use reservations and shares to prioritise access to ESX CPU

• Performance of CPU critical workloads may be disappointing regardless of CPU reservations or shares.

• Monitor ESX Ready time to determine the “penalty” of competing with other virtual machines

Page 30: Optimize Oracle On VMware (Sep 2011)

Typical VMWare disk configuration

Page 31: Optimize Oracle On VMware (Sep 2011)

Disk Resource Allocation

• Disk shares can be used to prioritize IO bandwidth.

• However, ESX often does not know underlying storage architecture

Page 32: Optimize Oracle On VMware (Sep 2011)

Performant VMware disk configuration

Page 33: Optimize Oracle On VMware (Sep 2011)

Optimal configuration

• See “Oracle Database Scalability in VMware® ESX” at www.vmware.com/oracle

• Each virtual disk directly mapped via RDM to dedicated RAID 0 (+1) group

41 Spindles!

Page 34: Optimize Oracle On VMware (Sep 2011)

VMWare disk configuration

• Follow normal best practice for physical disks• Avoid sharing disk workloads • Consider Raw Device Mapping (RDM)• If not, consider disk Shares• If you can’t optimize IO, avoid IO:

– Tune, tune, tune SQL– Prefer indexed paths– Memory configuration– Don’t forget about temp IO (sorts, hash joins)

Page 35: Optimize Oracle On VMware (Sep 2011)

Berts toolbox…

• Not pitching or selling anything here – just disclosure

• There are lot’s of good tools out there - pick whatever

• In brief – here’s what I used and why (its purpose):

– Load Generator = Benchmark Factory for Databases– Virtualization Monitor = Foglight for VMware

– Database Performance = Spotlight for Oracle & Foglight

Page 36: Optimize Oracle On VMware (Sep 2011)

Foglight for VMwareMonitor Shared Resources

Find & FixGenuine VMPerformance Issues

Help to SqueezeMaximum“Overall”Throughput

Page 37: Optimize Oracle On VMware (Sep 2011)

Benchmark Factory for DatabasesGenerate Database Workload

Stress theDatabase IntroducePerformance Issues

Help to ExposePotentialCandidates

Each step above is an individual test for my proposed best practices – and their results

Page 38: Optimize Oracle On VMware (Sep 2011)

440% Improvement for Proper Setup

1080 msAverage ResponseTime

200 msAverage ResponseTime

Page 39: Optimize Oracle On VMware (Sep 2011)

Bert’s Top Ten Tricks …• Obtain a baseline test for relative comparisons• On the VM host, exclude VM clients from active, online virus scans• Remove Windows Indexing Service (because really don’t need fast

file system searches for an Oracle database)• Remove other extraneous Windows services (there are lots)• Change the VM host registry settings to improve file system IO for

databases• Optimize the VM host configuration and options• Optimize the VM client OS configuration and options for Oracle

database• Remove other extraneous VM client OS services and daemons• Change VM client file system settings to improve IO performance

for databases• Adjust VM client file system block size to more closely match

Oracle block size

Page 40: Optimize Oracle On VMware (Sep 2011)

Guy’s top ten tips

• Use a tuning methodology (tuning by layers)• Design with performance in mind• Index wisely• Know your tools• Optimize the optimizer• Tune SQL and PL/SQL• Minimize contention• Optimize memory• Tune IO last, but tune it• Exploit and tune RAC

See www.toadworld.com article: http://bit.ly/9lnxyy

Page 41: Optimize Oracle On VMware (Sep 2011)

Tuning by layers

Problems in one database layer can be caused or cured by configuration in the higher layer. Therefore:

2.Reduce application demand to its logical minimum by tuning SQL and PL/SQL, and optimizing physical design (partitioning, indexing, etc).

3.Maximize concurrency by minimizing contention for locks, latches, buffers, etc.

4. Minimize amount of physical IO by optimizing Oracle memory.

5.Reduce IO latency by providing adequate IO bandwidth and evenly distributing the resulting load.

Database Code Layer:Oracle software parses & optimizes SQL, manages

locks, security, concurrency , etc

Application Layer: Application code issues SQL (and PL /SQL) requests

to database

Memory layer:

Buffer cache (data blocks)Other shared memory caches

PGA (sorting and hash memory )

Disk layer :

Read/write table/index data Read/write temporary work areas

Redo and other log IO

Page 42: Optimize Oracle On VMware (Sep 2011)

Presenter:Bert Scalzo: [email protected]

www.bertscalzo.com

Guy Harrison: [email protected]

www.twitter.com/guyharrison

Questions and Answers …

Thank You

Page 43: Optimize Oracle On VMware (Sep 2011)

© 2010 Quest Software, Inc. ALL RIGHTS RESERVED.

End of Presentation

너를 감사하십시요 Thank You Danke Schön

Gracias 有難う御座いました Merci

Grazie Obrigado 谢谢