|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
因为ASP脚本语言非常简单,因此其代码也简单易懂,结合HTML代码,可快速地完成网站的应用程序。还无法完全实现一些企业级的功能:完全的集群、负载均横。ado|sessionOracle:OLEDBResource(Session)Pooling
byEricMaEMa@ompus.jnj.com
Databaseconnectivityisaprerequisitefortodaysdynamicallygeneratedwebpages.However,connectiontodatabasesisoneofthemostexpensiveoperationsonedoesfromwithinanASPpage,becauseoftheoverheadinvolvedindatabaseuserauthenticationandallocationofdatabaseresourcestohandleuserinteractionwiththedatabase,amongotherthings.Allthesecanaddsignificantlatencytoyourwebsite.Basedontherecentdiscussionsinthislist,itisapparentthateveryoneiskeenlyawareofthisissueandwouldliketominimizethenegativeimpactonperformancebyhavingtoconnecttodatabases.Foraprogrammerwithaclient/serverprogrammingbackground,itisnaturalforthepersontodesignasolutionbasedonusingadatabaseconnectionthatpersiststhroughanentireusersession.However,foraweb-basedapplication,thisisabigno-no(seethearticleat/advice/dbsessionapp.aspforreasonswhyyoushouldneverdothis).
Thebestpracticefordatabaseconnection(welimitourdiscussiontoOraclehere)fromanASPapplicationistoopentheconnectionatlateasyoucan,andcloseitassoonasyoucan,whichmeansyouopenandclosedatabaseconnectiononeveryASPpage.TheencouragedpracticeistousejustonesetofOracleusername/passwordforyourentireapplication,notonesetforeachuserasyoumaybeusedtodowithclient/serverapplications.Accesscontrolisnolongerperformedbythedatabase,butbyyourapplication.YoucansavetheADOconnectionstringinanapplicationvariableintheglobal.asafile.SomeotheralternativesincludesavingitinthewindowsRegistry,oruseanincludefilethathastheADOconnectioninformation,andincludethatfileinthepageswheredatabaseconnectionisrequired.
OpeninganewdatabaseconnectionforeachASPpagemaynotbeasbadasyouthink,becausefromADO2.0upyoucanutilizethe"resource(session)pooling"featureofferedbyMicrosoftsOLEDBProviderforOracle.ResourcepoolingissimilartoODBCconnectionpooling,whereaconnectionisreturnedtoapoolinsteadofbeingdestroyedimmediatelyafteritisclosedandsettonothinginyourcode.Seethefollowingarticleformoredetails:
http://msdn.microsoft.com/library/techart/pooling2.htm.
ThepurposeofthisFAQistodemonstratehowtoproperlysettheenvironmentonyourIIS/NTservertotakeadvantageofOLEDBresourcepooling.UnlikewithODBC,whereyoucanenablepoolingandsetthetimeoutparameterfromthe32-BitODBCutilityintheControlPanel,withOLEDByouhavetodirectlyworkontheRegistryitself.Again,thisisnotasscaryasitsounds.Todoso,youfirstdeterminetheversionofOLEDBProvideryouareusingbyrunningthescriptfoundat:http://www.learnasp.com/learn/connectioninfo.asp,thendependentontheversionyouhave,youmaydothefollowingsteps:
?IfyouareusingtheOLEDB2.0provideryoucandoresourcepoolingbutyoucannotmodifythedefaulttimeoutconfiguration(60seconds).Tosetupresourcepooling,addthefollowingsubkeyintheRegistry:
HKEY_CLASSES_ROOTCLSID{e8cc4cbe-fdff-11d0-b865-00a0c9081c1d}OLEDB_Services.MakesureyouusetheDWORDtype,andenterahexadecimalvalueof0xffffffff.
However,Isuggestthatyoudontusethe2.0versionoftheProvideranymorebecauseofpotentialmemoryleaks.SeethefollowingKBarticleformore:
http://support.microsoft.com/support/kb/articles/q194/3/87.asp
?IfyouusetheOLEDB2.1or2.5provider,inadditiontodoingtheabovestep,youcanconfigurethepoolingtimeoutparameterbyaddingthefollowingsubkey:
HKEY_CLASSES_ROOTCLSID{e8cc4cbe-fdff-11d0-b865-00a0c9081c1d}SPTimeout.AgainthisentryisofaDWORDtypeandyouenteradecimalvalueinseconds.Itisuptoyoutodecidethenumberofsecondyouwanttoset,dependingonhowbusyyoursiteisandhowfrequentthepagesneedtoaccessOracledata.
AKBarticledescribingtheabovestepcanbefoundat:
http://support.microsoft.com/support/kb/articles/q237/9/77.asp
Afteryoumaketheabovechanges,rebootyourNTServertomaketheRegistrychangestakeeffect.Thisisstepisnecessary.
Congratulations,nowyouareusingthewonderfulfeatureofOLEDBresourcepooling!Ihopefromtodayonyouwillnevereverthinkaboutcachingconnectionobjectsinsessionvariablesanymore!Treatitasevil!
Somesidenotesandobservations:
?WithOracle,inordertouseresourcepooling,youneedtoaddtheRegistrysubkey.Havingonly"OLEDBServices=-1"inyourconnectionstringisnotenough.
?IcameacrossthefollowingKBarticleinMSDNsayingOLEDBresourcepoolingisautomatica
结论:和PHP一样,ASP简单而易于维护,很适合小型网站应用,通过DCOM和MTS技术,ASP甚至还可以完成小规模的企业应用,但ASP的致命缺点就是不支持跨平台的系统,在大型项目开发和维护上非常困难。 |
|