SOAPUI压力测试的参数配置.docx
《SOAPUI压力测试的参数配置.docx》由会员分享,可在线阅读,更多相关《SOAPUI压力测试的参数配置.docx(10页珍藏版)》请在冰豆网上搜索。
SOAPUI压力测试的参数配置
SOAPUI压力测试的参数配置
ThedifferentLoadStrategiesavailableinsoapUIandsoapUIProallowyoutosimulatevarioustypesofloadovertime,enablingyoueasilytesttheperformanceofyourtargetservicesunderanumberofconditions.SincesoapUIalsoallowsyoutorunmultipleLoadTestssimultaneously (seeanexamplefurtherdown),acombinationofLoadTestscanbeusedtofurtherassertthebehaviourofyourservices.SelectthedesiredStrategyforyourLoadTestfromtheStrategyToolbarintheLoadTestWindow:
LetshavealookatthedifferentLoadStrategiesavailableandseehowtheycanbeusedtododifferenttypesofLoad/Performancetests.
1. SimpleStrategy-Baseline,LoadandSoakTesting
TheSimpleStrategyrunsthespecifiednumberofthreadswiththespecifieddelaybetweeneachruntosimulatea"breathingspace"fortheserver.Forexampleifyouwanttorunafunctionaltestwith10threadswith10secondsdelay,setThreadsto10,delayto10000andrandomtohowmuchofthedelayyouwanttorandomize(iesettingitto0.5willresultindelaysbetween5and10seconds).WhencreatinganewLoadTestthisisthedefaultstrategyandsetatarelativelylowload(5threadswith1000msdelay).
TheSimpleStrategyisperfectforBaselinetesting.Useittoassertthethebasicperformanceofyourserviceandvalidatethattherearenothreadingorresourcelockingissues.Rampupthenumberofthreadswhenyouwantdomoreelaborateloadtestingorusethestrategyforlong-runningsoaktests.
Sinceitisn'tmeanttobringyourservicestotheirknees,asetuplikethiscanbeusedforcontinuousload-testingtoensurethatyourserviceperformsasexpectedundermoderateload;setupabaselinetestwithnorandomizationofthedelay,addLoadTestAssertionsthatactasasafetynetforunexpectedresultsandautomateitsexecutionwiththecommand-lineLoadTestrunnerormavenplugins.
2. FixedRateStrategy–Simplewithatwist
OnethingthattheSimpleStrategydoesnotdoisguaranteeanumberofexecutionswithinacertaintime,forexampleifyoumightwanttostartyourTestCase10timeseachsecondnomatterhowlongittakestoexecute.UsingtheSimpleStrategyyoucouldsetup10ThreadsandadelaycompensatingfortheaveragegapbetweentheendoftheTestCaseandthestartofthenextsecond,butthiswouldbehighlyunreliableovertime.TheFixed-Ratestrategyshouldbeusedinstead;settherateasdesired(10inourcase)andoffyougo;thestrategywillautomaticallystarttherequirednumberthreadsforthissettingattemptingtomaintaintheconfiguredvalue.
Ashintedintheheadline,therearesometwistshere:
whatifourTestCasetakesmorethanonesecondtoexecute?
TomaintaintheconfiguredTPSvalue,thestrategywillinternallystartnewthreadstocompensateforthis;afterawhileyoumighthavemanymorethan10threadsrunningduetothefactthattheoriginaloneshadnotfinishedwithinthesetrate.Andnotsurprisinglythiscouldcausethetargetservicetogetevenslower,resultinginmoreandmorethreadsbeingstartedto"keepup"withtheconfiguredTPSvalue.Asyouprobablyguessedthe"MaxThreads"settingishertopreventsoapUIfromoverloading(bothitselfandthetargetservices) inthissituation,specifyingavalueherewillputalimitonthemaximumnumberofthreadsthesoapUIwillbeallowedtostarttomaintaintheconfiguredTPS,ifreachedtheexistingthreadswillhavetofinishbeforesoapUIwillstartanynewones.
The"RequestLevel"settingwillattempttomaintaintheTPSnotontheTestCaseexecutionlevelbutontherequestlevelinstead,forexampleifyouhaveadata-drivenLoadTestoraTestCasewithmanyrequests,youwanttheTPSsettingtoapplynotontheexecutionleveloftheentireTestCasebutontherequestlevel.
Inanycase,theFixedRatestrategyisusefulforbaseline,loadandsoak-testingifyoudon’trunintothe"ThreadCongestion"problemdescribedabove.Ontheotherhand,youmightprovokethecongestion(maybeevenincombinationwithanotherLoadTest)toseehowyourserviceshandlethisorhowtheyrecoverafterthecongestionhasbeenhandled.
3. VariableLoadStrategies
Thereareseveralstrategiesthatcanbeusedtovaryload(thenumberofthreads)overtime,eachsimulatingadifferentkindofbehavior.Theycanbeusefulforrecoveryandstresstesting,butjustaswellforbaselinetesting,eitherontheirownorincombinationwithotherstrategies.Let'shaveaquicklook:
1.Variancestrategy –thisvariesthenumberofthreadsovertimeina“sawtooth”manorasconfigured;settheIntervaltothedesiredvalue andtheVariancetothehowmuchthenumberofthreadsshoulddecreaseandincrease.Forexampleifwestartwith20threads,setintervalto60andVarianceto0.8,thenumberofthreadswillincreasefrom20to36withinthefirst15seconds,thendecreasebackto20andcontinuedownto4threadsafter45seconds,andfinallygobackuptotheinitialvalueafter60seconds.IntheStatisticsDiagramswecanfollowthisvarianceeasily:
2.BurstStrategy - thisstrategyisspecificallydesignedforRecoveryTestingandtakesvariancetoitsextreme;itdoesnothingfortheconfiguredBurstDelay,thenrunstheconfigurednumberofthreadsforthe“BurstDuration” andgoesbacktosleep.Hereyoucould(andshould!
)setthenumberofthreadstoahighvalue(20+)tosimulateanonslaughtoftrafficduringashortinterval,thenmeasuretherecoveryofyoursystemwithastandardbase-lineLoadTestcontainingbasicperformance-relatedassertions.Letstrythiswithaburstdelayanddurationof10secondsfor60seconds;
Herecanseetheburstsofactivityinthediagram,pleasealsonotethattheresolutionhasbeenchangedto250ms(fromthedefault"data"value),otherwisewenothavehadanydiagramupdatesduringthe"sleeping"periodsoftheexecution(sincenodatawouldhavebeencollected).
3.The ThreadStrategy letsyoulinearly changethenumberofthreadsfromoneleveltoanotherovertherunoftheLoadTest.It’smainpurposeisasameanstoidentifyatwhichlevelcertainstatisticschangeoreventsoccur,forexampletofindatwhichThreadCountthemaximumTPSorBPScanbeachievedortofindatwhichThreadCountfunctionaltestingerrorsstartoccurring. Setthestartandendthreadvalues(forexample5to50)andsetthedurationtoarelativelylongduration(I useatleast30secondsperthreadvalue,inthisexamplethatwouldbe1350seconds)togetaccuratemeasurements(moreonthisbelow).
4.GridStrategy –thisstrategyallowstospecificallyconfiguretherelativechangeinnumberofthreadsovertime,itsmainuseforthisismoreadvancedscenarioandrecoverytesting,whereyouneedtoseetheservicesbehaviorundervaryingloadsandloadchanges.Forexampleletssayyouwanttorunfor60secondswith10,20,10,40,10threads.ConfigureyourLoadTesttostartwith10threadsandthenenterthefollowingvaluesintheGrid:
BothvaluesarestoredrelativetothedurationandactualThreadCountoftheLoadTest;ifyouchangethese,thecorrespondingGridStrategyvalueswillberecalculated. Runningthetestshowsthefollowingoutput:
5.ScriptStrategy –thescriptstrategyistheultimatecustomizationpossibility;thescriptyouspecifyiscalledregularly (The"StrategyInterval"settingintheLoadTestOptionsdialog)andshouldreturnthedesirednumberofthreadsatthatcurrenttime.Returningavalueotherthanthecurrentonewillstartorstopthreadstoadjustforthechange.Thisallowsforanykindofvarianceofthenumberofthreads,forexamplethefollowingscriptrandomizesthenumberofthreadsbetween5and15.
Runningthiswiththestrategyintervalsetto5000thenumberofthreadswillchangeevery5seconds:
Thepossibilitieshereareendless.
4. StatisticsCalculationandThreadCountChanges
Manyofthesestrategieswillchangethenumberofthreadswhichhasanimportantimpactonthestatisticscalculationthatyouneedtobeawareof;whenthenumberofthreadschanges,thiswillusuallychangetheresponsetimesofthetargetservices,resultinginachangeinavg,tps,etc. butsincetheLoadTesthasalreadyrunatapreviousnumberofthreadstheresultsforthoserunswillskewtheresultforthenewThreadCount.
Forexampleletssayyouhavebeenrunningat5threadsandgotandaverageto500ms.UsingtheThreadStrategyyouincreasethenumberofthreadsgradually;whenrunning6threadstheaverageincreasesto600msbutsincethe“old”valuescollected for5threadsarestillthere,thesewillintotalresultinaloweraverage.Therearetwoeasywaystoworkaroundthis;selectthe“ResetStatisticsonThreadCountchange”valueintheLoadTestOptionsdialog,ormanuallyresetthestatisticswiththecorrespondingbuttonintheLoadTesttoolbar;ineithercaseoldstatisticswillbediscarded.ToseethisinactionletsdoaThreadCountStrategytestfrom10to20threadsover300seconds(30secondsperthread),belowyoucanseeresultsbothwiththissettinguncheckedandthenchecked;
Inthelatteryouseethe“jumps”instatisticseachtimetheyareresetwhenthenumberofthreadschanges,graduallylevelingouttoanewvalue.ThefinalTPScalculatedat20threadsdiffersabout10%betweenthesetwo,showinghowthelowerresults“impact”thehigherones.
5. RunningMultipleLoadTestsSimultaneously
Ok,letshaveaquicklookatthis;we'llcreateonebaselinetestwiththesimplestrategyandalownumberofthreads,andatthesametimerunaburststrategytoseehowthebaselinetestperformance"recovers"aftertheburst;
Hereyoucanseethesimplestrategy(bottomdiagram)recoveringgradua