LOGO OA教程 ERP教程 模切知识交流 PMS教程 CRM教程 开发文档 其他文档  
 
网站管理员

微软建议的ASP性能优化28条守则(2)

admin
2010年7月3日 13:25 本文热度 5718
[p][b]技巧 21:启用浏览器和代理缓存[/b][/p] [p]  在默认情况下,asp 禁止在浏览器和代理中进行缓存。这是有意义的,因为就实质而言 asp 页面是动态的,上面有随时间不断变化的潜在信息。如果页面不要求在每个视图上进行刷新,您应启用浏览器和代理缓存。这可使浏览器和代理在一定的时间内使用页面的“缓存”副本,您可以控制时间的长短。缓存可以大大减轻服务器上的负载,缩短用户的等待时间。[/p] [p]  哪一种动态页面可作为要缓存的页面呢?下面举一些例子:[/p] [p]  天气预报页面,在此页面上,每隔 5 分钟更新一次天气预报。 [br]  列出新闻条目或新闻稿的主页,它一天更新两次。 [br]  共同基金业绩列表,在此列表中,基本统计信息每隔几小时更新一次。 [br]  注意,在使用浏览器或代理缓存的情况下,web 服务器上记录的访问次数减少了。如果您想准确地测量所有页面视图或张帖公布,您就不希望使用浏览器和代理缓存。[/p] [p]  浏览器缓存由 http“过期”报头控制,该报头由 web 服务器发送给浏览器。asp 提供两个简单的机制发送此报头。要设置页面使其过多少分钟后到期,则应设置 response.expires 属性。下面的例子告诉浏览器内容在 10 分钟内过期:[/p] [p]<% response.expires = 10 %>[/p] [p]  若将 response.expires 设置为负数或 0,则禁用缓存。一定要使用大的负数,如 -1000(略多于一天),以避免服务器和浏览器时钟之间的不匹配。第二个属性 response.expiresabsolute 将使您设置内容过期的具体时间:[/p] [p]<% response.expiresabsolute = #may 31,2001 13:30:15# %>[/p] [p]  您可以不使用 response 对象设置过期时间,而将 标记写进 html,通常写在 html 文件的 部分。一些浏览器将遵照此指令,而代理则不然。[/p] [p][/p] [p]  最后,您可以使用 response.cachecontrol 属性,指示其内容是否可以让 http 代理缓存。若将此属性设置为“public”,代理就可以缓存此内容。[/p] [p]<% response.cachecontrol = ?public? %>[/p] [p]  在默认情况下,此属性被设置为“private”。注意,对于显示某用户特定数据的页面,不应启用代理缓存,因为代理可能给用户提供属于其他用户的页面。[/p] [p]#p#[/p] [p][b]技巧 22:尽可能使用 server.transfer 代替 response.redirect[/b][/p] [p]  response.redirect 让浏览器请求另一个页面。此函数常用来将用户重定向到一个登录或错误页面。因为重定向强制请求新页面,结果是浏览器必须到 web 服务器往返两次,且 web 服务器必须多处理一个请求。iis 5.0 引入了一个新的函数 server.transfer,它将执行转移到同一台服务器上的另一个 asp 页。这样就避免多余的浏览器-web-服务器的往返,从而改善了总体系统性能以及缩短了用户的响应时间。检查“重定向”中的“新的方向”,上面应该是 server.transfer 和 server.execute。[/p] [p]  另请参见 leveraging asp in iis 5.0,了解 iis 5.0 和 asp 3.0 新功能的完整列表。[/p] [p][b]技巧 23:在目录 url 中使用后斜杠[/b][/p] [p]  一个相关的技巧是确保在指向目录的 url 中使用后斜杠 (/)。如果您省略了后斜杠,浏览器就会向服务器发出请求,只是为了告诉服务器,它在请求目录。浏览器就会发出第二个请求,将斜杠附加到 url 后面,只有此后,服务器才能以该目录的默认文档或目录列表(如果没有默认文档且启用了目录浏览的话)响应。附加斜杠可省去第一个、无用的住返。为便于用户阅读,可以省略显示名称中的后斜杠。[/p] [p]  例如,写:[/p] [p]http://msdn.microsoft.com/workshop[/p] [p]  这也适用于指向 web 站点上主页的 url:使用下面的:,而不使用 。[/p] [p][b]技巧 24:避免使用服务器变量[/b][/p] [p]  访问服务器变量会使 web 站点向服务器发出一个特殊请求,并收集所有服务器变量,而不只是您请求的那个变量。这种情况类似于,在发霉的阁楼上,在一个文件夹中查找某个文件。当您想要找那个文件时,您必须去阁楼上,先找到文件夹,然后才能找到这份文件。当您请求服务器变量时,发生的情况是一样的 - 您第一次请求服务器变量时,就会使性能受到影响。后面的对其它服务器变量的请求,则不会对性能产生影响。[/p] [p]  决不要访问非限定的 request 对象(例如,request("data"))。对于不在 request.cookies、request.form、request.querystring 或 request.clientcertificate 中的项目,则隐式调用 request.servervariables。request.servervariables 集合比其它集合慢得多。[/p] [p][b]技巧 25:升级到最新和最出色的[/b][/p] [p]  系统组件是恒定的,我们建议您将它们升级到最新和最好的配置。最好升级到 windows 2000(因此,也应升级到 iis 5.0、ado 2.5、msxml 2.5、internet explorer 5.0、vbscript 5.1 和 jscript 5.1)。在多处理器计算机上,实施 iis 5.0 和 ado 2.5 可显著改善性能。在 windows 2000 下,asp 可以很好地扩展到四个处理器或更多,而在 iis 4.0 下,asp 的扩展性不能超出两个处理器。在应用程序中使用的脚本代码和 ado 越多,升级到 windows 2000 之后,性能的改善就会越多。[/p] [p]  如果目前还不能升级到 windows 2000,您可以升级到 sql server、ado、vbscript 和 jscript、msxml、internet explorer 和 nt 4 service packs 的最新版本。它们均可提高性能和可靠性。[/p] [p][b]技巧 26:优化 web 服务器[/b][/p] [p]  有多种 iis 优化参数可以改善站点性能。例如,对于 iis 4.0,我们常常发现,增加 asp processorthreadmax 参数(参见 iis 文档)可以显著改善性能,特别是在倾向于等待后端资源(如数据库)或其它中间产品(如屏幕刷)的站点上。在 iis 5.0 中,您可能发现启用 asp thread gating 比查找一个 aspprocessorthreadmax 最佳设置效率更高,这一点现在已为大家所熟知。[/p] [p]  有关较好的参考资料,参见下面的优化 iis。[/p] [p]  最佳的配置设置取决于(其中一些因素)应用程序代码、运行所在的系统硬件和客户机工作负荷。找到最佳设置的唯一方法是进行性能测试,这是我们在下一个技巧中所要讨论的。[/p] [p][b]技巧 27:进行性能测试[/b][/p] [p]  正如我们在前面已经讲过,性能是一个特征。如果您想要改善站点的性能,那么就制定一个性能目标,然后逐步改进,直到达到目标为止。不要,就不进行任何性能测试。通常,在项目结束时,再作必需的结构调整已经为时太晚,您的客户将为此感到失望。将性能测试作为您日常测试的一部分来进行。可以对单个组件分别进行性能测试,如针对 asp 页或 com 对象,或将站点作为一个整体来测试。[/p] [p]  许多人使用单个浏览器请求页面,来测试 web 站点的性能。这样做就会给您一个感觉,即站点的响应能力很好,但这样做实际上并不能告诉您在负载条件下站点的性能如何。[/p] [p]  一般情况下,要想准确地测试性能,您需要一个专门的测试环境。此环境应包括硬件,其处理器速度、处理器数量、内存、磁盘、网络配置等方面与生产环境的硬件相似。其次,您必须指定客户机的工作负荷:有多少同时的用户,他们发出请求的频率,他们点击页面的类型等等。如果您没有站点实际使用情况的数据,您必须估计一下使用的情况。最后,您需要一个可以模拟预期客户机工作负荷的工具。有了这些工具,您就可以开始回答诸如“如果我有 n 个同时的用户,那么需要多少服务器?”之类的问题。您还可以找出出现瓶颈的原因,并以此为目标进行优化。[/p] [p]  下面列出了一些好的 web 负载测试工具。我们特别推荐 microsoft web application stress (was) 工具包。was 可使您记录测试脚本,然后模拟数百或成千上万个用户访问 web 服务器。was 报告很多统计信息,包括每秒钟的请求数,响应时间分布情况和错误计数。was 有丰富的客户机界面和基于 web 的界面两种,web 界面可使您进行远程测试。[/p] [p]  一定要阅读 iis 5.0 tuning guide。[/p] [p][b]技巧 28:阅读资源链接[/b][/p] [p]  下面是一些与性能有关的出色的资源链接。如果您想了解有关信息,请阅读 developing scalable web applications。[/p] 资源 [p]优化 asp 脚本 [br]  developing scalable web applications[/p] [p]  got any cache? nancy winnick cluts 著[/p] [p]  maximizing the performance of your active server pages,nancy winnick cluts 著[/p] [p]  15 seconds: performance section[/p] [p]  enhancing performance in asp - part i,wayne plourde 著[/p] [p]  when is better worse? weighing the technology trade-offs,nancy winnick cluts 著[/p] [p]  speed and optimization resources,charles carroll 著[/p] [p][b]优化 iis[/b][/p] [p]  the art and science of web server tuning with internet information services 5.0[/p] [p]  leveraging asp in iis 5.0,j.d. meier 著[/p] [p]  tuning iis 4.0 for high volume sites,michael stephenson 著[/p] [p]  tuning internet information server performance,mike moore 著[/p] [p]  navigating the maze of settings for web server performance optimization,todd wanke 著[/p] [p]  managing internet information server 4.0 for performance,hans hugli 著[/p] [p][b]ado 和 sql server[/b][/p] [p]  top ten tips: accessing sql through ado and asp,j.d. meier 著[/p] [p]  improve the performance of your mdac application,suresh kannan 著[/p] [p]  pooling in the microsoft data access components,leland ahlbeck 和 don willits 合著[/p] [p]  sql server: performance benchmarks and guides[/p] [p]  improving the performance of data access components with iis 4.0,leland ahlbeck 著[/p] [p]  microsoft data access components (mdac) and activex data objects (ado) performance tips,leland ahlbeck 著[/p] [p]  microsoft sql server 7.0 practical performance tuning and optimization - the server perspective,damien lindauer 著[/p] [p]  microsoft sql server 7.0 practical performance tuning and optimization - the application perspective,damien lindauer 著[/p] [p]  accessing recordsets over the internet,dino esposito 著[/p] [p][b]asp 组件和线程模型[/b][/p] [p]  asp component guidelines,j.d. meier 著[/p] [p]  q243548: info: design guidelines for vb components under asp[/p] [p]  threading models explained,nancy winnick cluts 著[/p] [p]  so happy together? using activex components with active server pages,nancy winnick cluts 著[/p] [p]  developing active server components with atl,george reilly 著[/p] [p]  agility in server components,neil allain 著[/p] [p]  building high-performance middle-tier components with c++,jon flanders 著[/p] [p]  active server pages and com apartments,don box 著[/p] [p]  house of com: active server pages,don box 著[/p] [p]  house of com: contexts,don box 著[/p] [p]  house of com: performance trade-offs of the windows 2000 component execution environment,don box 著[/p] [p]  building com components that take full advantage of visual basic and scripting,ivo salmre 著[/p] [p]  component design principles for mts[/p] [p][b]词典组件[/b][/p] [p]  creating a page cache object,robert coleridge 著[/p] [p]  abridging the dictionary object: the asp team creates a lookup-table object,robert carter 著[/p] [p]  caprock dictionary[/p] [p]  site server commerce edition includes a dictionary component[/p] [p][b]会话状态[/b][/p] [p]  q175167: howto: persisting values without sessions[/p] [p]  q157906: howto: how to maintain state across pages with vbscript[/p] [p]  xml-based persistence behaviors fix web farm headaches,aaron skonnard 著[/p] [p]  house of com: stateless programming,don box 著[/p] [p][b]性能和扩展性[/b][/p] [p]  blueprint for building web sites using the microsoft windows dna platform[/p] [p]  server performance and scalability killers,george reilly 著[/p] [p]  microsoft visual studio scalability center[/p] [p]  fitch & mather stocks 2000[/p] [p]  tuning the fmstocks application[/p] [p]  high-performance visual basic apps,ken spencer 著[/p] [p]  duwamish books,phase 4[/p] [p]  top windows dna performance mistakes and how to prevent them,gary geiger 和 jon pulsipher 合著[/p] [p]  building from static html to high-performance web-farms,shawn bice 著[/p] [p][b]工具[/b][/p] [p]  microsoft web application stress tool[/p] [p]  i can't stress it enough -- load test your asp application,j.d. meier 著[/p] [p]  windows dna performance kit[/p] [p]  monitoring events in distributed applications using visual studio analyzer,mai-lan tomsen 著[/p] [p][b]书目[/b][/p] [p]  professional active server pages 3.0,wrox press(特别是第 26 章:optimizing asp performance,george reilly 和 matthew gibbs 合著)。[/p] [p]  microsoft internet information services 5.0 resource guide(与 windows 2000 server resource kit 在一起),microsoft press。[/p] [p]  microsoft internet information server resource kit(用于 iis 4.0),microsoft press。[/p] [p]  programming distributed applications with com and microsoft visual basic 6.0,ted pattison 著,microsoft press。[/p] [p]  effective com,don box、keith brown、tim ewald 和 chris sells 合著;addison-wesley。[/p] [p]  developing web usability: the practice of simplicity,jakob nielsen 著,new riders。[/p] [p][b]asp web 站点[/b][/p] [p]  microsoft technet for iis[/p] [p]  learnasp.com[/p] [p]  4guysfromrolla.com[/p] [p]  15seconds.com[/p] [p]  asptoday.com[/p] [p]  asp101.com[/p] [p]  asplists.com。许多专业的邮件列表包括:[/p] [p]  fast code! [br]  asp advanced [br]  not newbiestate management [br]  scalability [br]  visual basic components [br]  xml [br]  c++/atl component building [br]  useit.com: web 可用性[/p] [p][b]asp 样式[/b][/p] [p]  asp best practices,george reilly 著[/p] [p]  asp quick lessons,charles carroll 著[/p] [p]  planning for asp,john meade 著[/p] [p]  asp guidelines,j.d. meier 著[/p] [p][b]xml[/b][/p] [p]  inside xml performance,chris lovett 著[/p] [p]  inside msxml3 performance,chris lovett 著[/p]

该文章在 2010/7/3 13:25:30 编辑过
关键字查询
相关文章
正在查询...
点晴ERP是一款针对中小制造业的专业生产管理软件系统,系统成熟度和易用性得到了国内大量中小企业的青睐。
点晴PMS码头管理系统主要针对港口码头集装箱与散货日常运作、调度、堆场、车队、财务费用、相关报表等业务管理,结合码头的业务特点,围绕调度、堆场作业而开发的。集技术的先进性、管理的有效性于一体,是物流码头及其他港口类企业的高效ERP管理信息系统。
点晴WMS仓储管理系统提供了货物产品管理,销售管理,采购管理,仓储管理,仓库管理,保质期管理,货位管理,库位管理,生产管理,WMS管理系统,标签打印,条形码,二维码管理,批号管理软件。
点晴免费OA是一款软件和通用服务都免费,不限功能、不限时间、不限用户的免费OA协同办公管理系统。
Copyright 2010-2024 ClickSun All Rights Reserved