1 / 35

IIS6.0 综述 及在其基础上建立高性能的 Web 应用程序 Win301/315

IIS6.0 综述 及在其基础上建立高性能的 Web 应用程序 Win301/315. 陈硕 ShuoC@microsoft.com 软件开发及测试工程师 Server Management Group Microsoft Corporation. 讲座内容浏览:. 介绍 IIS6.0 新的 体系 结构 : Performance Reliability Security Manageability 程序设计环境 ASP .NET ASP ISAPI 利用 Windows .NET Server 新特色. IIS6.0 体系结构的改善 :.

spencer
Download Presentation

IIS6.0 综述 及在其基础上建立高性能的 Web 应用程序 Win301/315

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. IIS6.0综述及在其基础上建立高性能的Web应用程序Win301/315IIS6.0综述及在其基础上建立高性能的Web应用程序Win301/315 陈硕 ShuoC@microsoft.com 软件开发及测试工程师 Server Management Group Microsoft Corporation

  2. 讲座内容浏览: • 介绍IIS6.0 新的体系结构: • Performance • Reliability • Security • Manageability • 程序设计环境 • ASP .NET • ASP • ISAPI • 利用Windows .NET Server 新特色

  3. IIS6.0体系结构的改善: Performance, security, reliability & manageability

  4. Windows 2000 Windows .NET Server IIS5.0 and IIS6.0 内部设计对照:

  5. Web Garden Application Pool 1 Application Pool 2 INETINFO WAS W3WP.EXE W3WP.EXE W3WP.EXE W3WP.EXE W3WP.EXE W3WP.EXE DLLHOST.exe ASP.NET ISAPI ASP.NET ISAPI ASP.NET ISAPI ASP.NET ISAPI ISAPI Extensions (ASP, etc.) ISAPI Extensions (ASP, etc.) ISAPI Extensions (ASP, etc.) metabase CLR App Domain CLR App Domain CLR App Domain CLR App Domain Config Mgr Process Mgr CLR App Domain CLR App Domain CLR App Domain CLR App Domain ISAPI Filters ISAPI Filters ISAPI Filters HTTP.SYS Response Cache Namespace Mapper Send Response Req Queue Req Queue Req Queue HTTP Engine IIS 6.0 ArchitectureThe transition from IIS5 to IIS6 INETINFO Aspnet_wp.exe metabase ASP.NET ISAPI CLR App Domain CLR App Domain CLR App Domain TCP/IP

  6. Application Pool Application Pool 运行可靠新的增强:应用程序隔离 – 新处理模型 • 完全进程(process)隔离 • 1 or more processes talking directly to the kernel • Independent from other processes • Kernel-mode queuing • Application Pools • Web Gardens Worker Process Worker Process WAS ISAPI Extensions ISAPI Extensions ISAPI Filters ISAPI Filters HTTP.sys

  7. W3WP W3WP User Kernel HTTP HTTP DPC DPC ISR ISR 纵向伸展特色: Processor Affinity: • 极少的资源竞争(locks) • 处理器关系 • 减小处理器缓存失误数 • 分区负荷 • 拆开网站或应用程序的负荷; 将其限制与系统特定资源之中 <IIsApplicationPool Location ="/LM/W3SVC/AppPools/FinanceAppPool" AppPoolFriendlyName="Finance Applications" AutoShutdownAppPoolExe="nlb.exe" AutoShutdownAppPoolParams="drain 173.45.23.41" LoadBalancerCapabilities="1" SMPAffinitized="TRUE" SMPProcessorAffinityMask="4026531840" . </IIsApplicationPool>

  8. 实例对照NILE app(商务程序) • E-commerce benchmark from Doculabs; Measures the overall performance of some scenarios that are commonly used by e-commerce sites • Logon, browse items, search, shopping cart operations, check out • Static file caching, data-base operations, session state management 4P: +15% 8P: +25%

  9. 运行可靠性(Reliability)一览: • 新处理模式解决应用程序的隔离 (Worker process for application isolation) • 回收功能(recycling)及健康测试(Health detection) • 更完善的调试及进程管理

  10. Hosting Site isolation and resource use • Application Pool resource usage is “virtual” • HTTP.SYS listens to site endpoints (IP/Port/Header) • User-mode system resources consumed only when a site receives requests • If active site does not get a request for 20 minutes, worker process is idled out • Increased IIS worker process limit on Windows .NET

  11. Can create 1 or more application pools Each served by 1 or more W3WP.exe’s. Each W3WP.exe serves only 1 pool. Reqs routed directly to pool by HTTP.sys Isolate apps based on: Site/Customer Functionality Reliability Making Applications More ReliableApplication Pools

  12. What is it? Periodically restart applications based on: Uptime # of requests Scheduled time Memory consumption On-demand Why use it? Refresh apps to ensure availability Prevent bad apps from taking over the system Making Applications More ReliablePeriodic Process Recycling

  13. demo Application Pool and Recycling

  14. SSL(安全套接字层)的拓展 • SSL StreamFilter can be hosted in LSASS.EXE process (can give up to 25% throughput gains in SSL loads) • Reduction of cross-process marshalling and context switching for SSL interactions • Not hosted by default as could force service packs to require reboots • No application change – just configure through registry switch • Progressive SSL thread pool • Load-aware and adjusts parallelism depending on load • Significant performance work on MP machines • (increases up to 2X for some workloads on 8P machines)

  15. Securing ApplicationsLocked Down by Default • IIS not installed on a clean install by default • And disabled on upgrades • IIS serves static files by default • 404’s for disabled application extensions (404.2) • Substatus codes logged in W3C logs by default now • Only 404 sent to client • ASP.NET, FPSE, & FTP not installed by default • ASP.NET enabled when installed • Only Known extensions served • Unknown extension = 404.3 • New Security Console used to enable app extensions: • Individual ISAPI extensions and CGI’s • Example: Enable FPSE & ASP.NET to publish via VS.NET for Intranet or Dev server • Or just enable ASP.NET to allow ASP.NET apps to be served.

  16. Demo: Web Service Extensions Console

  17. Metabase.xml MBSchema.xml Making .NET Applications More ManageableMetabase improvements • XML Metabase • Metabase now stored in XML • Auto-versioning: Like an automatic backup • Edit while running • Make changes directly to the metabase.xml file while IIS is running • Any editor can be used – Notepad.NET, PERL, etc. UI ADSI Admin Base Objects

  18. UI ADSI Admin Base Objects Metabase.xml MBSchema.xml Making .NET Applications More ManageableMetabase improvements – Import/export • Export/import metabase config to/from XML • Options include • Export/Import inherited properties • Export/Import node only (or entire subtree) • Password encrypt exported file • Use w/ASP .NET XCOPY deployment of apps • Export IIS6 metabase config for .NET app • store in .NET app directory • Import app metabase config file after XCOPY

  19. demo 运行中更改 配置除据库(metabase)

  20. IIS6.0 程序设计环境:

  21. Web应用程序的可伸缩性(Scalability) • Stateless • Application code and components can be restarted cheaply; Session state is managed externally in some sort of state store • Low initialization costs • Applications should avoid doing heavy processing at startup or assume that they will run for a long time; • Multi-instance-able • All the components / classes of an application should be happy to have multiple instances in separate processes without namespace or locking issues • Expect administrator imposed limits • Your application is likely to have • CPU limits; • Memory Limits; • Processor affinity imposed

  22. With Cache Request Response Request Response Dynamic Kernel Caching GET http://www.acme.com/store/sproketcatalog.aspx Without Cache <%@ OutputCache Duration="10" VaryByParam="none" %>

  23. Increasing .NET Scale And PerformanceCaching responses in HTTP.SYS • ASP .NET is able to cache complete responses in HTTP.SYS • Responses marked as Location=“Server” • Cached responses served straight from HTTP.SYS • Much faster when served from kernel – no user-mode transition • Your apps won’t see requests if served from cache • Invalidation of cached complete responses (Server) same as in IIS5 <%@ OutputCache Location=“Server” … %>

  24. Worker process Worker process Worker process Worker process ISAPI Extension ISAPI Extension ISAPI Extension ASP .NET ISAPI filter ISAPI filter ISAPI filter ISAPI filter Increasing .NET Scale And PerformanceIIS 6 Web Gardens and Processor Affinity • Web Gardens • App Pool with > 1 worker process • Connection-based routing w/in Garden • Processor Affinitization • Bind app pool process/es to 1 or more CPUs • Mask-based config Web Garden application pool WAS HTTP.SYS

  25. ~50% ASP Considerations • Run ASP in COM+ MTA for sites that have “Both” and “Free” threaded components • Cache adjustments – avoid ASP page compilation • Template cache should be big enough to hold “hot” pages • Script engine cache should also hold “hot” pages • Intrinsic improvements for ASP • ASP does asynchronous writes to the network (more efficient in terms of number of threads in the OS) • ASP uses VectorSend() under the covers

  26. ASP .NET 应用指南 • 内核模式(kernel)控制输出缓存 • Better performance than current output cache (kernel served) • Should consider what information needs to be absolutely current and what information can be a little stale • 缓存粹片(Fragment cache) • Use for expensive-to-construct portions of pages (PartialCaching attribute) • 进程内运行(in-process) • All processing done in-process • Default on Windows 2000 involved a process hop • Try to stay in managed code – avoid Interop if possible • If you are running Interop scenarios run COM object in process • ASP .NET 在 .NET Server 上的内在收益 • ASP .NET leverages new ISAPI features • ASP .NET/IIS implement a fast path for common case response headers ASP .NET / CLR ISAPI W3WP.EXE 用户模式 内核模式 HTTP.SYS

  27. API(处理应用程序接口)/技术选择托管代码(Managed Code)与非托管代码(Unmanaged Code) • Very high level of functionality • Great performance • Rapid application development • Wide variety of languages to choose from • Familiar to VB and script writers Managed Unmanaged • More control over the request • Highest potential performance • Complete control over processing chain • C and C++

  28. ISAPI Native W3WP.EXE user kernel HTTP.SYS ISAPI 应用指南 • C++/native code through ISAPI • Do NOT do your processing on the ISAPI thread • Always send using asynchronous send APIs; ISAPI on Windows .NET Server is no longer tolerant of synchronous writes – performance will suffer • Use VectorSend/FinalSend combination • Where possible cache responses • Cleanup in TerminateExtension() calls – they will be called frequently • Review use of ISAPI Filters and if possible try and remove

  29. 利用Windows .NET 新特色

  30. Applications Architecture On Multiprocessor Machines Request 2 Request 1 • Application Locks are the scalability killer for managed and unmanaged code • Look at usage of synchronization primitives • Monitors, WaitHandle class (Mutex, AutoReset Events, ReaderWriter locks, etc.) • Consider partitioned data structures for applications • Should every request lock and traverse a long linked list? • Can request data be instanced on a per request basis • How is my global data referenced?

  31. 如何编写更好的程序? • General • Stateless applications (manage state separately) • Low initialization cost/processing • Applications should be able to be multi-instanced • Expect limitations • CPU • Memory and others

  32. 如何编写更好的程序? • ASP .NET • Use intrinsic response caching • Avoid COM+ Interop – if have to try to minimize the number of transitions between managed and unmanaged code (marshalling cost) • Run everything in-process • ASP • Setting cache appropriately • Check if COM+ components are “Free” or “Both” threaded; Run in the MTA • When on .NET Server: Run COM+ components in process (Local Server)

  33. 如何编写更好的程序? • ISAPI • Review for best practices • Don’t execute on the IIS thread, maintain small threadpool • Use Async IO wherever possible (that includes using Async version of VectorSend and WriteClient() • Re-architect ISAPI filters into extensions • Consider changing WriteClient calls to VectorSend and specify FinalSend flag when complete • Determine if certain dynamic responses can be stale; If true, cache them

  34. 阅读参考: • Internet Information Server (IIS) 6 Overview • http://www.microsoft.com/TechNet/prodtechnol/iis/evaluate/iis6ovw.asp?frame=true • ASP .NET Performance Tips • http://www.gotdotnet.com/team/asp/ASP.NET%20Performance%20Tips%20and%20Tricks.aspx • Managed Code Analysis Tools • Intel’s VTune http://www.intel.com/software/products/vtune/vtune60/index.htm • Numega’s TrueTime www.numega.com • Sessions • DEV330: ASP .NET: Performance Tuning and Caching

More Related