Pages

Sunday, August 7, 2011

How does your web site perform?

I found a cool site to test my web site's performance: http://www.webpagetest.org/
All you have to do is give them the URL of your site. I did a performance test test for my .NET 007 site. :)

Performance review

First byte time, Keep-Alive (no of objects in the request), GZip text (Compressing objects), Compress images, cache static, combine css/java script, Use a CDN - mine is Google - , minify JS(use gzip), proper cookie usage
Above statistics will show how to improve performance by minimizing no of objects, compressing images and java script files, minimizing requests for java script or css files by combining them in a one file etc. with the url and performance gain if you optimize the site.

Also, there will be a full optimization check list for each request.

Page speed optimization check






 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
Content break down by MIME type

Gaphical representation of the requests for different content such as images, java script files, css pages are given here.




Content break down by domain

Requests for the web site by different domains and the no. of bytes are shown.

Screen shots

Screen shots of the web site during different stages in page rendering are also given with a summery of what actually happened during rendering.

Finally, this is my result:
http://www.webpagetest.org/result/110807_TW_18Q13/

Precedence in ASP.NET themes

If you specify a theme in page directive or web config, it takes precedence over the design properties given in the control itself.

Difference between skin file and style sheet (CSS)

Both skin files and style sheets come under ASP.NET themes (App_Themes) to give your site a consistent and customized look and feel. It is a convenient method for a developer to apply design across the web site with minimal effort.

Difference between skin file and CSS file
  • Skin file has .skin file extension and style sheet has .css file extension.
  • Skin file can be used on ASP.NET server controls, where as style sheets are used in standard HTML mark up elements.
  • Skin file is rendered from IIS server. CSS is rendered from the client's browser. (That's why when you apply CSS elements, you get browser specific issues.)
Example for Skin file

-asp:GridView runat="server" SkinId="gridviewSkin" BackColor="White" -
-AlternatingRowStyle BackColor="Blue" /-
-/asp:GridView-
 
Example for CSS file

body
{
          background-color :#F0F0F0;
}

Friday, August 5, 2011

How database records reside in memory?

A physical database file (.mdf) is logically divided in to data pages. A data page can go up to 8 KB. SQL Server stores records(rows) in a data page. One row cannot splitt across two data page and because of that a row can grow up to 8 KB only. If an index is added in to the table and ASC or DESC is specified, records are sorted according that order.

Wednesday, August 3, 2011

Create a graph visualization using ANTLR

You can use Graphviz software to generate a graphical version of a tree or graph.
Download link: http://www.graphviz.org/Download..php


Create the parse tree
  1. First, create ANTLR StringTemplates for tree and edges. (design specification for the image)
  2. Get the file content and create an AntlrFileStream to be given as an input to the lexer.
  3. Then create a token stream using the lexer and invoke the rules to parse the tree.
Generate the dot file

Create an instance of ANTLR DotTreeGenerator.
Create the output file.
 StringTemplate st = dotTreeGenerator.ToDOT(ParsedTree, new CommonTreeAdaptor(), _treeStringTemplate, _edgeStringTemplate);
You can create .dot file using this string template. (Ex: test.dot)


Generate image of the graph

Give the .dot file as input and specify the output format. (Ex: .png)
Execute the following command:
dot.exe -Tpng test.dot -O test.png

An image of the input graph will be created with the given design specifications.

Sample image generated for SQL query is given below:

CREATE TABLE Persons
(
P_Id int NOT NULL PRIMARY KEY,
LastName varchar(255) NOT NULL,
FirstName varchar(255)
)

Tuesday, August 2, 2011

What's new in ASP.NET 4.0: ViewStateMode

View state is used to persist application data between page requests using client side resources.
If scalability is a major concern over performance, this will be a better mechanism to persist data as storing data in the page itself will reduce the contention on the server, thus allowing more user requests.

However, transfering data between request is costly if you are adding lengthy text to the view state.
So, disabling view state when not required will improve the performance of the application.

You can enable or disable the view state using EnableViewState and ViewStateMode properties in page or control level. Also you can use EnableViewState in web.config to manage it in application level.

How ViewStateMode works?

If you EnableViewState = true in page level, by default ViewStateMode is set as inherit in controls in that page which will enable view state for all the control. By changing the ViewStateMode of the page, you can configure the behaviour for controls as you wish.
However, if you set Page.EnableViewState = false, the view state is disabled no matter the value given in the ViewStateMode. 
You can set Page.ViewStateMode = enabled and Control.EnableViewState = false and Control.ViewStateMode = disabled to disable view state for selected controls.

You can do the vice versa, to disable view state for page and it's controls and then enable view state for selected controls.

Monday, August 1, 2011

What View Engine does?

View engine will handle the rendering of HTML content. (View in MVC)

One gaze @ ASP.NET Page life cycle!

Install IIS 7.5 in Windows Server R2

IIS 7.5 is not installed in Windows Server R2 by default. This is how to install it manually.
  1. All Programs > Administrative Tools > Server Manager > Roles Summery
  2. Roles Summery > Add Roles > Add Roles wizard
  3. Select Web Server (IIS)
  4. Select the roles you want (Ex: WebDav publishing) in Role Services
  5. Add Role Services required for ASP.NET Application Development such as ISAPI Filters, ISAPI Extentions and .NET Extensibility.

ASP.NET request processing in a nut shell!

In IIS 6.0 a seperate worker process (w3wp.exe) is created for each application pool which is known as "IIS worker process isolation" , where as in IIS 5.0, there can be more than one application in a worker process. (aspnet_wp.exe)