显示标签为“performance”的博文。显示所有博文
显示标签为“performance”的博文。显示所有博文

2009年4月10日星期五

April 10th-11th Links:Velocity,C#,SQL SERVER,ReSharper

.NET
    How to optimize passing complex data to the server

ASP.NET
    1) Favicon
    2) Titles And Meta Data
    Your page title is more important element for SEO and is also important so that users know what's on the page.Make sure it changes on every page and relate to that page's content.
    3) Cross-Bowser Checks
    4) Proofread
    5) Links
    6) Graceful Degradation
    7) Validation
    8) RSS Link
    The common conversion is to put a small RSS icon in the browser's address bar.
    9) Analytics
    10) Sitemap
    Adding a sitemap.xml file to your root directory allows the major search engines to easily index your website
    11) Defensive Design
    The most commonly overlooked defensive design element is the 404 page.
    12) Optimize

C#

Javascript

Velocity
    1) High Availability
    2) Notifications
    3) Local Caching
    4) Management & Monitoriting
    5) Better Integration

WEB

IE
    1) IE8 Opens More Connections Per Host Name
    2) IE8 Has a New Process Model
    3) All IE8 Tabls,Window and Pop-ups Belong To Same Browser Session
    4) The IE8 Process Model is Configurable
    5) Compatibility Workarounds for IE8
    6) New Built-in Developer Tools For IE9
    7) How to Use HttpWatch with IE8

ReSharper

SQL SERVER
    1. Logical Query Processing Phases- Order of Statement Excution
    1) FROM -> ON -> OUTER -> WHERE -> GROUP BY-> CUBE|ROLLUP->HAVING->SELECT->DISTINCT->ORDER BY->TOP

Other
    neXpert is an add-on to Fiddler which automates the classic performance best practice checks and produces a HTML report on the issues found in a Fiddler capture.
    3.4 Great Tools to use visual Studio

2009年3月17日星期二

March 17th:C#,Debug,HTML

C#
    This post touches on four major expression subjects:
    1) String Comparison - does a string contain a particular sub-string?
    a. finding valid HTML tags- RegEx.Matches return MactchCollection
    valid html tags: Regex HTMLTag = new Regex(@"(<\/?[^>]+>)");
    2) Splitting a string into segments(分割,部分)- we will take an IPv4 address and retrieve its dotted components
    a. splitting decimal Tcp/IP address looks like xxx.xxx.xxx.xxx with x being a decimal number
    Regex tcpIp = new Regex(@"(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})");
    3) String Replacement
    4) Substitution Patterns
    5) Stricter input validation- how to harden your expressions
    1) The ? conditional evaluation operator
    example:int max = (x > y) ? x : y;
    2) Null-Coalesce(合并,联合) operator(??)
    example:obejct e = ( c != null ) ? c : d; => object e = c ?? d;
    3) Object Initializers
    Customer c = new Customer{ Name="James",Address="204 Lime Street"};(c# 3.0)
    4) The using statement
    5) Aliases(别名) for long winded namespaces and types
    example: using Word = Microsoft.Office.Interop.Word;
                     Word.Application = new Word.Application(){ Visible = true};
    6) Nullable objects
    example: Nullable x = null;
     int? x =  null;
    7) Automatic Properties(c# 3.0)
    8) Type inference(c#3.0 var)
    note: There is no performance impact results form using type inference.The compiler does all the work figuring out the data type at compile time.
    9) Lambda Expressions
    10) string.IsNullOrEmpty
    Optional and named parameters in C# 4.0
    Example:app.Document.open(ref filename,ref missing.......);
    app.Documents.open(@"c:\Document.docx",Readonly:true);
    1) what is an anonymous type?
      One important motivation(动机)for this was to make code written with LINQ easier to read.Anonymous types simply mean that you don't specify the type- but let the complier do it instead.
    2) what is the beneficial for Anonymous type?
    a. simple definitions,simplified
    b. using anonymous types for creating arrays
    c. Saving time and code with anonymous types
    d. Combining Lambda expressions with Queries
    3) other questions?
    a. Is var typesafe? yes
    b. Is there a performance penalty(处罚,征罚) for using "var"? no
    c. On using anonymous definitions in large projects

Debugger
    1) Install the Visual Studio 2008 QFE( Quick-Fix-Engineering)
    2) Start Visual Studio 2008 and bring up Tools > Options > Debugging > General
      Turn OFF the "Enable Just My Code" setting
      Turn ON the "Enable Source Server Support" setting
    3) Next,bring up the "Symbols" page and set the symbols download URL and a cache location.
      Set the symbol file location to be:http://referencesource.microsoft.com/symbols

Sliverlight

Other

2009年2月25日星期三

February 26th-27th Links:SQL SERVER,ASP.NET PERFORMANCE

C#
    1. Creating SOLID Code: Sigle Responsibility Principle- Episode-Codebetter.com 

ASP.NET

IIS

SQL SERVER
    The query statement is related Table : sys.foreign_keys,sys.foreign_key_columns,sys.objects
    Third Normal Form(3NF) is most preferable normal form in RDBMS.Nomalization is the process of designing a data model to efficiently store data in database.The rules of 3NF are mentioned here:
    1) Make a sperate table for each set of related attributes, and give each table a privary key.
    2) If an attribute deponds on only part of a muil-valued key. remove it to a separate table.
    3) If an attribute don't contribute(有助) to a description of the key, remove it to a separate table.
    Normalization is very close to concept of Object Oriented schema's and it stores one data at only one place by removing all the redundant(多余的) data. Normalization comes at cost of performance.
    PS: 1NF: 数据库表中的字段都是单一属性,不可再分.
           attribute1   attribute2  attribute3(attribute3.1,attribute3.2...)
           2NF: 数据库表中不存在非键字段对任一候选关键字段的部分函数依赖.
           (studentId, courseName)->(studentName,age,grade,credits(学分))
           but
           (courseName)->(credits)
           (studentId)->(studentName,age)
           3NF: 数据表中不存在非关键字段对任一候选关键字段的传递函数依赖。
          (studentId)->(name,age,college,colleagePhone,colleageLocation)
   but
          (studentId)->(colleage)->(colleagePhone,colleageLocation)

2008年10月12日星期日

关于在IIS6.0创建webSites的最佳做法(Best practices for creating websites in IIS6.0)

每一次我创建一个IIS网站,我总要做一些步骤,我考虑这些步骤是为了网站更好的性能,更加易于维护,以及具有伸缩性。下面是我做的步骤:
1. 对每一个web应用程序创建一个可分离的应用程序池(application pool)
我总是创建 一个分离的application pool为每一个应用程序,因为这样我可以为应该用程序的回收选择不同的计划时间。一些通信压力大的websites有一个长一些的回收计划时间,一些通信小的webSites能一个短点的回收计划时间。此外,而且我能够为这些app pool选择不同的进程数量。这些使用web garden模式的应用程序得益于多个进程,另外在进程中使用了session以及memory cache的进程则有一个单一的进程服务于它的app pool中。所以将所有的应用程放在DefaultAppPool 下不能给我一个弹性去控制每一个网站。
你创建许多的app pool,那么你的应用程序就有更多可用的ASP.NET线程。每个w3wp.exe都有它自己的线程池(thread pool)。因此,如果一些应该程序被特定的w3wp.exe阻塞着,其它的应用程充也能够开开心心的运行在他们分离下app pool的w3wp.exe中。每一个app pool都 管理着他们自己的w3wp.exe实例。所以,我的首要规则是:我总是创建一个新的app pool为一个新的web应用程序并且以其网站domain命名,或者更加有意义的名字。例如,你创建一个网站叫alzabir.com,则可以将app pool命令为alzabir.com 。
2.禁止DefaultAppPool,以免你将网站加到DefaultAppPool中去而犯错误。
3.设置IIS的一些日志属性。
4.设置IIS的错误页(404),以及打一个缓存cache 。
5.设置IIS6.0的Gzip compression.
6.明确设置你的网站的asp.net的版本。
具体操作如下所示:
如下二图所示:首先你创建一个新的app pool,然后你创建一个新的webSite或虚拟目录。打开Properties -> Home Directory tab->Select the new app pool.注意将DefaultApplicationPool禁止。

image
image

接下来,你应该映射正确的host headers到你的网站中去。怎么去做呢?打开WebSite并且点击“Advanced”按钮。加上两个映射地址domain.com和www.domain.com 。注意,许多时间,人们总忘记去映射domain.com。然后许多访问者都跳过类型www的前缀,结果得到页面无法访问的情况。操作如下图所示:

image

再接下来配置一些日志信息:

image

这样很方便得可以去分析网站。如果你想去测量你的宽带消耗对于特定的网站,你应该去勾选Bytes Sent ;如果你想去测量不同页面的执行时间并且找出运行慢的网页,你应该去勾选 Time Taken;如果你想去测量特殊的访问者和回访者,你应该去勾选Cookie。如果你想去知道进入你网站的前一个网站地址或者发给你的一些搜索引擎地址,你应该去勾选Referer。接下来你就可以使用分析式具去分析了,例如,使用open source AWStats.
但是,如是你使用Google Analytics或者其它一些分析工具,你应该将它们关闭,特别是Cookie和Referer,因为它们在日志中占有非常多的空间。如果你使用ASP.NET Forms Authentication并且是一个中等通信规模的网站,则来自于每一个请求的世大的cookie每一周将产生GB(gigabytes)日志数量的数据。
image

然后,我加了一个Default.aspx作为一个默认的内容页。当用户访问网站没有任何.aspx页同名字的时候,便如alzbir.com,他们得到一个default.aspx页面(如上图所示)。

image

再接一来,我要做以下事情(如上图所示):
1) 打开内容过期时间。这将使静态文件,例如images,javascripts,css文件不用从服务器上下载一遍又一遍。这一个设置将明显的提高你的网站性能。
2) 移除X-Powered-by:ASP.NET header。你实在是不需要它,除非你想附加一个Visual Studio Remote Debugger到你的IIS,否则,它将在每一个response中发送21bytes到你的客户端。
3) 加上一个"From" header并且设置它的服务器名称。我做这一步在每一个webserver,并指定不同的名字。它很清楚的可以看到来自那一个的服务品的requests正在被工作。当你想去机检测负载平衡的时候,它很楚的可以知道一个指定的服务器是否正在发送requests .

image

我设置一个404 控制一些aspx,这样我能显示一个友好的错误信息。但是另外一个原因是去使用这个客户端的映射来实现可扩展性的URL。具体请看这篇文章

image

然后确定你的ASP。NET2.0,3.0和3.5的网站设置ASP.NET2.0。
最后,我重复的提醒你必须去打开IIS6.0 GZIP compressionThis turns on the Volkswagen V8 engine that is built into IIS to make your site screaming fast