仓酷云
标题:
ASP网站制作之OLEDB Resource(Session) Pooling (在A...
[打印本页]
作者:
第二个灵魂
时间:
2015-1-16 23:14
标题:
ASP网站制作之OLEDB Resource(Session) Pooling (在A...
因为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的致命缺点就是不支持跨平台的系统,在大型项目开发和维护上非常困难。
作者:
老尸
时间:
2015-1-17 13:52
ASP(ActiveServerPages)是Microsfot公司1996年11月推出的WEB应用程序开发技术,它既不是一种程序语言,也不是一种开发工具,而是一种技术框架,不须使用微软的产品就能编写它的代码,能产生和执行动态、交互式、高效率的站占服务器的应用程序。
作者:
精灵巫婆
时间:
2015-1-24 10:42
弱类型造成潜在的出错可能:尽管弱数据类型的编程语言使用起来回方便一些,但相对于它所造成的出错几率是远远得不偿失的。
作者:
再现理想
时间:
2015-1-26 23:29
我认为比较好的方法是找一些比较经典的例子,每个例子比较集中一种编程思想而设计的。
作者:
再见西城
时间:
2015-1-27 22:16
那么,ASP.Net有哪些改进呢?
作者:
爱飞
时间:
2015-2-2 08:05
我想问如何掌握学习节奏(先学什么再学什么)最好详细点?
作者:
愤怒的大鸟
时间:
2015-2-7 17:32
我们必须明确一个大方向,不要只是停留在因为学而去学,我们应有方向应有目标.
作者:
若相依
时间:
2015-2-22 17:41
多看多学多思。多看一些关于ASP的书籍,一方面可以扩展知识面一方面可以鉴借别人是如何掌握、运用ASP的;多学善于关注别人,向同学老师多多学习,不论知识的大小;多思则是要将学到的知识灵活运用。
作者:
飘灵儿
时间:
2015-3-7 01:09
尽管MS自己讲C#内核中更多的象VC,但实际上我还是认为它和Java更象一些吧。首先它是面向对象的编程语言,而不是一种脚本,所以它具有面向对象编程语言的一切特性,比如封装性、继承性、多态性等等,这就解决了刚才谈到的ASP的那些弱点。
作者:
莫相离
时间:
2015-3-20 22:40
先学习用frontpage熟悉html编辑然后学习asp和vbscript建议买书进行系统学习
欢迎光临 仓酷云 (http://ckuyun.com/)
Powered by Discuz! X3.2