Designing and Developing for Performance.docx
《Designing and Developing for Performance.docx》由会员分享,可在线阅读,更多相关《Designing and Developing for Performance.docx(21页珍藏版)》请在冰豆网上搜索。
DesigningandDevelopingforPerformance
DesigningandDevelopingforPerformance
Goodsystemperformancebeginswithdesignandcontinuesthroughoutthelifeofyoursystem.Carefullyconsiderperformanceissuesduringtheinitialdesignphase,anditwillbeeasiertotuneyoursystemduringproduction.
Thischaptercontainsthefollowingsections:
∙OracleMethodology
∙UnderstandingInvestmentOptions
∙UnderstandingScalability
∙SystemArchitecture
∙ApplicationDesignPrinciples
∙WorkloadTesting,Modeling,andImplementation
∙DeployingNewApplications
OracleMethodology
SystemperformancehasbecomeincreasinglyimportantascomputersystemsgetlargerandmorecomplexandastheInternetplaysabiggerroleinbusinessapplications.Inordertoaccommodatethis,Oraclehasproducedaperformancemethodologybasedonyearsofdesigningandperformanceexperience.Thismethodologyexplainsclearandsimpleactivitiesthatcandramaticallyimprovesystemperformance.
Performancestrategiesvaryintheireffectiveness,andsystemswithdifferentpurposes,suchasoperationalsystemsanddecisionsupportsystems,requiredifferentperformanceskills.Thisbookexaminestheconsiderationsthatanydatabasedesigner,administrator,orperformanceexpertshouldfocustheireffortson.
Systemperformanceisdesignedandbuiltintoasystem.Itdoesnotjusthappen.Performanceproblemsareusuallytheresultofcontentionfor,orexhaustionof,somesystemresource.Whenasystemresourceisexhausted,thesystemisunabletoscaletohigherlevelsofperformance.Thisnewperformancemethodologyisbasedoncarefulplanninganddesignofthedatabase,topreventsystemresourcesfrombecomingexhaustedandcausingdown-time.Byeliminatingresourceconflicts,systemscanbemadescalabletothelevelsrequiredbythebusiness.
UnderstandingInvestmentOptions
Withtheavailabilityofrelativelyinexpensive,high-poweredprocessors,memory,anddiskdrives,thereisatemptationtobuymoresystemresourcestoimproveperformance.Inmanysituations,newCPUs,memory,ormorediskdrivescanindeedprovideanimmediateperformanceimprovement.However,anyperformanceincreasesachievedbyaddinghardwareshouldbeconsideredashort-termrelieftoanimmediateproblem.Ifthedemandandloadratesontheapplicationcontinuetogrow,thenthechancethatyouwillfacethesameprobleminthenearfutureisverylikely.
Inothersituations,additionalhardwaredoesnotimprovethesystem'sperformanceatall.Poorlydesignedsystemsperformpoorlynomatterhowmuchextrahardwareisallocated.Beforepurchasingadditionalhardware,makesurethatthereisnoserializationorsinglethreadinggoingonwithintheapplication.Long-term,itisgenerallymorevaluabletoincreasetheefficiencyofyourapplicationintermsofthenumberofphysicalresourcesusedforeachbusinesstransaction.
UnderstandingScalability
Thewordscalabilityisusedinmanycontextsindevelopmentenvironments.Thefollowingsectionprovidesanexplanationofscalabilitythatisaimedatapplicationdesignersandperformancespecialists.
WhatisScalability?
Scalabilityisasystem'sabilitytoprocessmoreworkload,withaproportionalincreaseinsystemresourceusage.Inotherwords,inascalablesystem,ifyoudoubletheworkload,thenthesystemwouldusetwiceasmanysystemresources.Thissoundsobvious,butduetoconflictswithinthesystem,theresourceusagemightexceedtwicetheoriginalworkload.
Examplesofbadscalabilityduetoresourceconflictsincludethefollowing:
∙Applicationsrequiringsignificantconcurrencymanagementasuserpopulationsincrease
∙Increasedlockingactivities
∙Increaseddataconsistencyworkload
∙Increasedoperatingsystemworkload
∙Transactionsrequiringincreasesindataaccessasdatavolumesincrease
∙PoorSQLandindexdesignresultinginahighernumberoflogicalI/Osforthesamenumberofrowsreturned
∙Reducedavailability,becausedatabaseobjectstakelongertomaintain
Anapplicationissaidtobeunscalableifitexhaustsasystemresourcetothepointwherenomorethroughputispossiblewhenit'sworkloadisincreased.Suchapplicationsresultinfixedthroughputsandpoorresponsetimes.
Examplesofresourceexhaustionincludethefollowing:
∙Hardwareexhaustion
∙Tablescansinhigh-volumetransactionscausinginevitablediskI/Oshortages
∙Excessivenetworkrequests,resultinginnetworkandschedulingbottlenecks
∙Memoryallocationcausingpagingandswapping
∙Excessiveprocessandthreadallocationcausingoperatingsystemthrashing
Thismeansthatapplicationdesignersmustcreateadesignthatusesthesameresources,regardlessofuserpopulationsanddatavolumes,anddoesnotputloadsonthesystemresourcesbeyondtheirlimits.
SystemScalability
ApplicationsthatareaccessiblethroughtheInternethavemorecomplexperformanceandavailabilityrequirements.SomeapplicationsaredesignedandwrittenonlyforInternetuse,buteventypicalback-officeapplications,suchasageneralledgerapplication,mightrequiresomeoralldatatobeavailableonline.
CharacteristicsofInternetageapplicationsincludethefollowing:
∙Availability24hoursaday,365daysayear
∙Unpredictableandimprecisenumberofconcurrentusers
∙Difficultyincapacityplanning
∙Availabilityforanytypeofquery
∙Multitierarchitectures
∙Statelessmiddleware
∙Rapiddevelopmenttimescale
∙Minimaltimefortesting
Figure 2-1illustratestheclassicworkloadgrowthcurve,withdemandgrowingatanincreasingrate.Applicationsmustscalewiththeincreaseofworkloadandalsowhenadditionalhardwareisaddedtosupportincreasingdemand.Designerrorscancausetheimplementationtoreachitsmaximum,regardlessofadditionalhardwareresourcesorre-designefforts.
Figure2-1WorkloadGrowthCurve
Textdescriptionoftheillustrationpfgrf213.gif
Applicationsarechallengedbyveryshortdevelopmenttimeframeswithlimitedtimefortestingandevaluation.However,baddesigngenerallymeansthatatsomepointinthefuture,thesystemwillneedtobere-architectedorre-implemented.IfanapplicationwithknownarchitecturalandimplementationlimitationsisdeployedontheInternet,andiftheworkloadexceedstheanticipateddemand,thenthereisrealchanceoffailureinthefuture.Fromabusinessperspective,poorperformancecanmeanalossofcustomers.IfWebusersdonotgetaresponseinsevenseconds,thentheuser'sattentioncouldbelostforever.
Inmanycases,thecostofre-designingasystemwiththeassociateddowntimecostsinmigratingtonewimplementationsexceedsthecostsofproperlybuildingtheoriginalsystem.Themoralofthestoryissimple:
designandimplementwithscalabilityinmindfromthestart.
FactorsPreventingScalability
Whenbuildingapplications,designersandarchitectsshouldaimforasclosetoperfectscalabilityaspossible.Thisissometimescalledlinearscalability,wheresystemthroughputisdirectlyproportionaltothenumberofCPUs.
Inreallife,linearscalabilityisimpossibleforreasonsbeyondadesigner'scontrol.However,makingtheapplicationdesignandimplementationasscalableaspossibleshouldensurethatcurrentandfutureperformanceobjectivescanbeachievedthroughexpansionofhardwarecomponentsandtheevolutionofCPUtechnology.
FactorsPreventingLinearScalability
1.PoorApplicationDesign,Implementation,andConfiguration
Theapplicationhasthebiggestimpactonscalability.Forexample:
∙PoorschemadesigncancauseexpensiveSQLthatdoesnotscale.
∙Poortransactiondesigncancauselockingandserializationproblems.
∙Poorconnectionmanagementcancausepoorresponsetimesandunreliablesystems.
However,thedesignisnottheonlyproblem.Thephysicalimplementationoftheapplicationcanbetheweaklink.Forexample:
∙SystemscanmovetoproductionenvironmentswithbadI/Ostrategies.
∙Theproductionenvironmentcouldusedifferentexecutionplansthanthosegeneratedintesting.
∙Memory-intensiveapplicationsthatallocatealargeamountofmemorywithoutmuchthoughtforfreeingthememoryatruntimecancauseexcessivememoryusage.
∙Inefficientmemoryusageandmemoryleaksputahighstressontheoperatingvirtualmemorysubsystem.Thisimpactsperformanceandavailability.
IncorrectSizingofHardwareComponents
Badcapacityplanningofallhardwarecomponentsisbecominglessofaproblemasrelativehardwarepricesdecrease.However,toomuchcapacitycanmaskscalabilityproblemsastheworkloadisincreasedonasystem.
LimitationsofSoftwareComponents
Allsoftwarecomponentshavescalabilityandresourceusagelimitations.Thisappliestoapplicationservers,databaseservers,andoperatingsystems.Applicationdesignshouldnotplacedemandsonthesoftwarebeyondwhatitcanhandle.
LimitationsofHardwareComponents
Hardwareisnotperfectlyscalable.MostmultiprocessormachinescangetclosetolinearscalingwithafinitenumberofCPUs,butafteracertainpointeachadditionalCPUcanincreaseperformanceoverall,butnotproportionately.TheremightcomeatimewhenanadditionalCPUoffersnoincreaseinperformance,orevendegradesperformance.Thisbehaviorisverycloselylinkedtotheworkloadandtheoperatingsystemsetup.
Note:
ThesefactorsarebasedonOracleServerPerformancegroup'sexperienceoftuningunscalablesystems.
SystemArchitecture
Therearetwomainpartstoasystem'sarchitecture:
∙HardwareandSoftwareComponents
∙ConfiguringtheRightSystemArchitectureforYourRequirements
HardwareandSoftwareComponents
Thissectiondiscusseshardwareandsoftwarecomponents.
HardwareComponents