DCSIMG
February 2009 - Posts - Yevgeni Frolov

Yevgeni Frolov

February 2009 - Posts

New Visual Studio 2010 UI was revealed!

Recently at VSLive! San Francisco 2009 new Visual Studio 2010 key features were presented by Jason Zander, brief description of it is published this article .

In Jason’s blog  several screenshots of our new toy can be found.

Web Performance: Stress tests to IIS 7.0 data compression.

In one of my previous post about IIS 7.0 data compression I’ve described how to enable this functionality, without drilldown to recommended configuration values .

In this great post Scott Forsyth known specialist in IIS performance area made a great job on testing IIS 7.0 server performance under various configurations and with different files sizes.

It helped me a lot , so I recommend to add this post to your favorites:

IIS 7 Compression. Good? Bad? How much?

Enjoy.

TFS Error: Windows Live Messenger is not running.

Well, yes that is a message I’ve got recently. Actually this message comes in two variations:

When Windows Live Messenger process does not exists and I try to open a Team Explorer:

image

When Windows Live Messenger process is active and I try to open Team Explorer:

image

Here can be found great description of the problem by Stuart Preston. Briefly, the problem is with Power Tools for TFS that tries to look for registry value that does not exists.

Stuart’s solution contain step of windows registry changes, since I don’t like to change registries I’m not familiar with, I would like to propose another solution:

After Installing power tool for TFS – new node can be found in a Team Explorer called “Team Members”. Right click, select “Personal Settings” shows this window

image

In a “Collaboration” group box click on “Change” button gives an option to change Provider to “None” this way Power Tools will not search for Windows Live Messenger on next load.

image

 

Enjoy.

IIS 7.0: New IP restrictions module

New module was released by Microsoft’s IIS team, It contains several improvements:

  • Blocking of IP address based on number of concurrent requests
  • Blocking of IP address based on number of requests over a period of time
  • Various deny actions
  • Logging of defined requests
  • Display currently blocked IP addresses
  • IPv6 support

Full description and download link can be found here:

IP restrictions module

Team Foundation Server: Alert changes in custom control.

Well TFS is not my specialty, but some time ago I was asked to develop custom control for one of our clients… This process is very easy and intuitive, so it did not took ages, as I thought in the beginning…

But  I’ve encountered small but very annoying(in UI aspect) problem. After implementing all the needed (IWorkItemControl interface etc.) and placing my custom control into standard work item, I’ve discovered that opened work item does not indicates that any change was made if changes are made in my custom control. This means that if a user will not push save button in Visual Studio IDE data that was changed in my custom control will be lost.

After a wile I’ve found a very simple solution:

Two properties that have to be implemented in IWorkItemControl interface:

1. WorkItemDatasource – holds a reference to a work item and should be casted to a WorkItem class.

2. WorkItemFieldName – holds a name of a field that defined in work item’s XML definition.

This row is the solution:

(WorkItemDatasource as WorkItem).Fields[WorkItemFieldName].Value = someValue;

Apparently updating “Value” property , not only changes the value, but also indicates to a work item that some changes were made. Now if user will try to close a work item without saving - Visual Studio IDE will alert him on attempt to close work item with unsaved data in it.

Enjoy and feel free to contact me if you have any questions.

At last – got my MCPD certification.

Well it took me awhile, but yes I’m MCPD Enterprise Developer now. I’ve started to teach young developers in our company long time before a I’ve ended my exams(maybe that’s why it took me more than a year, or not…). So I’ve seen how those certification can help to develop strong programming fundamentals and awareness of existing .NET technologies and tools.

Usually we run towards to another technological adventure without getting deep into fundamentals or exploring the full range of tools supplied with a platform. Microsoft Certifications program supplies a comprehensive guide into .NET world and I recommend to embrace it as apart of developers education in organizations.

For those of you who got .NET 2.0 certification and thinks about .NET 3.5 - there is an upgrade program for MCPD certified, like myself – two exams and you are there.

It’s never ends, but who said that it’s a bad thing, right?

Web Performance: Data compression with IIS 7.0

In one of my previous posts I’ve described a way to enable data compression in IIS 6.0 server. It was not a straightforward mission, but in IIS 7.0 the situation was CHANGED, and I mean it  - it’s a totally a different story.

Enable basic data compression

In IIS 7.0 basic data compression can be enabled by checking two checkboxes on configuration panel at IIS 7.0 management tool, without any need in changing configuration files. It can be enabled at each level of server hierarchy (Common server level, Website, web folder etc.) – meaning, data compression definition can vary between each folder in IIS server.

Data compression can be enabled by clicking on “Compression” icon in properties of IIS root node.

 

 image

Opened dialog contains standard data configuration. I’ve explained those properties in my previous post about IIS 6.0 data compression, it was not changed in IIS 7.0.

image

If “Compression” icon is clicked on any of IIS’s root node sub-levels, this dialog will be shown.

image

Customizing data compression

Data compression at IIS 7.0 server is highly customizable and, unlike IIS 6.0 server, can vary in each sub level of IIS server.

Files for customization:

In each of those files httpCompression XML node can be located for data compression customization.

<httpCompression    
    cacheControlHeader="string"    
    directory="\subdirectory\file"    
    doDiskSpaceLimiting="True|False"    
    dynamicCompressionDisableCpuUsage="integer"    
    dynamicCompressionEnableCpuUsage="integer"    
    expiresHeader="date and time"    
    maxDiskSpaceUsage="integer"    
    minFileSizeForComp="integer"    
    noCompressionForHttp10="True|False"    
    noCompressionForProxies="True|False"    
    noCompressionForRange="True|False"    
    sendCacheHeaders="True|False"    
    staticCompressionDisableCpuUsage="integer"    
    staticCompressionEnableCpuUsage="integer"
>      
    <scheme    
        dll="name of compression dll"    
        doDynamicCompression="True|False"    
        doStaticCompression=" True|False "    
        dynamicCompressionLevel="integer"    
        name="name of compression scheme"       
        staticCompressionLevel="integer"
    >
       <remove name="name of compression scheme" />
       <clear />
    <scheme/>   
    <dynamicTypes>...</dynamicTypes>       
    <staticTypes>...</staticTypes>
</httpCompression>

 

Tip:
Web.config file is most convenient place to configure data compression rate for application. This way there no need to configure settings on each target IIS server during deployment process.

By default “dynamicCompressionLevel” value is 0 and “staticCompressionLevel” is 7. Those values might be not optimal for your system. Web.config would be a good  place to change them. In some cases there is a need to define custom file types for a compression. All those can be solved by updating httpCompression node.

Here is the list of default values you should be familiar with:

dynamicCompressionDisableCpuUsage 90%
dynamicCompressionEnableCpuUsage 50%
staticCompressionDisableCpuUsage 100%
staticCompressionEnableCpuUsage 50%
dynamicCompressionLevel 0
staticCompressionLevel 7

Data compression throttling

IIS 7.0 opens for developers an ability to apply advanced logic into data compression mechanism. Besides standard compression level for static and dynamic files there is data compression throttling depending on current CPU ratio. This makes possible to define clear boundaries for a compression to reduce performance impact on running web applications.

After performing all the changes above - IIS server must be restarted to apply all those changes.

To check performance improvements use Fiddler or YSlow to monitor HTTP traffic.

IIS 7.0 version delivers highly flexible model for data compression helping developers to upgrade application’s performance without changing code.

Web Performance: AXD files compression.

In my previous post I’ve described how to enable data compression on IIS 6.0 server. The problem I’ve discovered while analyzing HTTP traffic with Fiddler and YSlow is that somehow IIS does not compresses WebResource.axd files. In ASP.NET websites with extensive use of Ajax this issue reduces site’s performance significantly, because of size and amount of axd files in use.

Screenshots below demonstrate results of enabling of IIS standard data compression during my tests(here can be found some explanations about YSlow usage):

Before enabling data compression on IIS:

 image

After enabling data compression on IIS:

image

Although data compression was enabled, axd file was not compressed without any obvious reason. To overcome this obstacle within ASP.NET applications HttpModule must be implemented. It will compress an axd files on http response. An implementation’s algorithm is pretty simple:

  1. Subscribe to BeginRequest and EndRequest events.
  2. On BeginRequest validate if any data compression can be applied on axd file. If not, bypass all module’s events.
  3. On EndRequest apply data compression to a axd file.  Standard .NET classes can be used to apply GZip or Deflate compression - DeflateStream and GZipStream. If browser supports deflate data compression – prefer it, because of performance reason, here are some explanations.
  4. Set response content type to “text\javascript” – caches file on client side.
  5. Set an expiration data to some reasonable time span – reduces number of server requests.

After applying suggested solution YSlow shows an ideal “A” grade:

image

By enabling this HttpModule, network utilization for ASP.NET application, using Ajax, reduced significantly because of a fact that axd files sizes are big without compression and there is no caching for those files by default.

If you have any questions about an implementation of HttpModule I’ll be glad to help. Any way  I’ve checked two examples that are ready for download :

  1. Link from Codeproject.
  2. An implementation by Miron Abramson

 

Hope this post will help to improve your applications…

Web Performance: Expiration data - IIS 6.0

In scenarios when your server is overloaded with an enormous amount of requests, you can (and probably should) use a great feature of IIS 6.0 - expiration date. This way after 5 minutes of “intensive”work number of web requests can be reduced significantly.

Lets see simple example of web page with and without expiration date enabled.

Page request without expiration date enabled:

image

The page performs 46 requests on first page visit and 40 requests when it’s cached. The explanation is very simple - when expiration date is not set, web browsers make request to a server to check if selected file needs to be updated.

Page request with expiration date enabled:

image

The number of requests was drastically reduced, instead of having 40 requests on load of cached page – there is only One request!

Warning!
Expiration date must be set only for static content(html pages , java script files,css styles etc.)

Here is step-by-step instructions on how to do it on IIS 6.0:

  1. Open IIS management console
  2. Right click on folder that contains static resources or on static file itself, select properties in a context menu
  3. Select an “HTTP Headers” tab page
  4. Check “Enable context expiration” checkbox
  5. Set a relevant expiration policy

 image

Tip:
When building folders structure for web application, group static resources to a separate folders,this way they are easier to manage. For example folder for scripts, folder for styles, folder for images etc. this way when set of expiration date is needed it can be done by selecting those folders.

Expiration date policy must be analyzed carefully before applying it, because of consequences of being wrong. Imagine that an expiration date of style file that was set to expire in a year, although you need to change site’s design every month…

Web Performance: Enable data compression on IIS 6.0 server.

In my previous post I've introduced YSlow - an Firebug’s add-on that helps to analyze and improve web site performance. One of the easiest ways to improve web application performance is to enable data compression. Enabling data compression on IIS 6.0 server can save up to 80% of network utilization by the price of up to 10% and often less than 1% of CPU ratio without changing single line of code.

Apparently, enabling data compression on IIS 6.0 is not that straight forward task as it looks. Most people that are using IIS as a hosting server mistakenly think that enabling data compression on “Web Sites properties” is enough… well it’s not - this is only the first step in that process.

So here is how it really goes step by step:

1.  Enable compression functionality on IIS server management tool:

  • Right click on “Web Sites” folder in IIS management tool , click on Properties
  • Select Service tab in opened dialog
  • Check “Compress application files”
  • Check “Compress static files”
  • Define a folder for compresses cache storage(possible to use a default)
  • Select a limitation mode for compressed cache (Only compressed static files are cached)

 

image

2.  Enable editing of meta data file manually:

  • Right click on IIS root, click on Properties
  • Check an “Enable Direct Metabase Edit” option

image 

3. Edit meta data file:

The meta data file called MetaBase.xml is located at %windir%\system32\inetsrv\MetaBase.xml.

Warning!

Changing MetaBase.xml can harm IIS server functionality if not handled properly, though it is crucial to backup file before making any changes.

XML compression configuration node name is “IIsCompressionScheme”. There are two such nodes in a MetaBase.xml file, one for Deflate compression algorithm and another for GZip compression algorithm - both nodes should be configured.

Attributes to be changed:

HcDynamicCompressionLevel attribute defines value from 0 to 10, when 0 is most light compression level. I would recommend to set it to 9 – it seems like an optimal “performance – compression ratio” relation.

Warning!

Setting a compression level to 10 causes high CPU utilization.

HcFileExtensions attribute defines a list of static files extensions that should be compressed.(Example: js, HMTL etc.)

Warning!

Do not enable data compression on files that are already compressed (jpg files for example).

HcScriptFileExtensions attribute defines a list of dynamic files extensions that should be compressed.(Example: aspx, asmx etc.)

 image

After performing all the changes above IIS server must be restarted to apply all those changes. To check performance improvements use Fiddler or YSlow to monitor HTTP traffic.

Summary

Data compression feature is a very powerful tool for reducing network traffic, yet, no code changes are required! Still it is only one of many tweaks that are available on IIS server. About some of those I will blog very soon…

Great resource for a blogger

Since I'm new to blogging I had to do some homework before I felt ready to start blogging. So I just have to recommend this great web site that has tons of valuable information for starting bloggers as myself and for pro's like you guys, so enjoy:

DailyBlogTips