Showing posts with label Misc Articles. Show all posts
Showing posts with label Misc Articles. Show all posts

Tuesday, October 18, 2011

Web Site performance


A modern web page requires the browser to make a number of requests to the web server for a page to download all its content. Most of the root cause analysis found that the web server spends 10-20 % of time in serving the dynamic part (code part) and rest of the time in serving most of the static content like CSS, JavaScript and Images. Correcting these web performance issues not only saves money by consuming less bandwidth but also saves money on infrastructure investments (less servers). Before we proceed some of the tools that help in monitoring the performance of web sites are Fiddler, Network Monitor and IIS logs. Fiddler and Network Monitor are freely downloadable from Microsoft.
Please remember the three key performance rules. All our performance suggestion will revolve around these rules
  •   Try to reduce the number of http calls to the server
  •   Send as little as possible
  •   Send as infrequently as possible

To do a performance improvement of a web site one should first consider
  •       Infrastructure Improvements which focus on IIS and other network settings 
  •       Frontend Improvements


Infrastructure Improvements

Let’s get started with the infrastructure improvements which include 5 key areas. They are HttpCompression, Content Expiration, Content Distribution Network (CDNs), eTags, HttpHeaders. Please note that the infrastructure and frontend improvements are not limited to the items that are discussed in this post.

HttpCompression: One of the performance rules is to send as little as possible. IIS by default allows you send request in Http Compression. It is possible to send the compressed http request with both IIS 6.0 and IIS 7 and above. In IIS 7 by default compress static files. The compressed version consumes a less bandwidth and at times it reduces bandwidth up to 30-50%. There are two important factor you must consider before enabling HttpCompression.

  • 1.      Check applicationHost.config file and make sure the images are not enabled for compression. Images have their own compression logic and might cause bad performance if IIS compression is enabled for images.
  • 2.      IIS 7 & above uses CPU for http compression. Although not official by Microsoft but it is likely to be around 1%.  IIS 7 has option to turn off the compression if the CPU usage goes beyond a certain preset limit. But looking at the benefits we are going to achieve it is advisable to enable it.


Content expiration: Based on the send as infrequent possible rule, we can use the client browser caching. Set up the up the expiration for all static content of your application. A good candidate for setting up the expiration are the static image, JavaScript files and CSS files. You may set the expiration based on your website needs.

Content Distribution Network (CDN): One of the items that we can think of is CDN. Let’s say a file which we want to refer in our internet site (say a JQuery file) instead of serving from our web server it is better to serve it from major player Microsoft etc. Major players have the CDN infrastructure to serve the page from a geographically closer location.
Although it adds some amount of performance improvement, one of the biggest disadvantages that it adds another failure point to your web application. If the major player site is down for some reason this will impact your site as well.

Removing E-Tags and Unnecessary Headers: One of the performance rules is ‘Send as little as possible’. By default IIS adds E-Tags and unnecessary headers like the version of ASP.Net etc with each request which you may not wish to show to the client browser. We may write a simple httpModule code to remove the unnecessary headers.
Note: we may need to have a careful consideration before trying something with the httpModules as it might have a negative impact as well.

Frontend performance Techniques
Externalize CSS & JavaScript: One of the performance rules again is to send as little as possible. With externalizing the CSS and JavaScript we can leverage the below

a.      Reduce the page size
b.      Allow reuse of the file
c.      Allows us to set the expiration of the file which helps in browser caching.

Minification and Consolidation: Again with respect to send as little as possible, minification and consolidation plays a major role. Often the JavaScript, CSS files have lots of comments, blank spaces which goes to production as is. While it is necessary for the developer to understand the comments it is not necessary to move the same files to production. Minification of the file removes all the unnecessary items that need not move to production. Consolidation again removes number of https calls to the server. So instead of having multiple try to consolidate files as much as possible.

Tools that can be used for this is MS Build.

Image optimization: Image optimization plays a major role in the in the send as little as possible rule mentioned earlier. Free tools like Paint.Net have a ways to compress the images. To human eye it would not make any difference between the compressed and uncompressed images.

CSS Sprite: If you have multiple small images, whenever you web site is request the client makes a call to the server for each of the images. To reduce the number of hits on the server we can use the CSS sprites, where we can club multiple images into a single image file and css to control which section of the image to be shown.

There are multiple CSS sprite tools available online which generate a single image file and CSS from a number of images.

Apart from the infrastructure and frontend improvements there are miscelinious performance options like caching, tools like YSlow, making async calls etc to improve the performance. Again those can be explored as whenever it is necessary. I hope you enjoyed the content and happy coding.

Tuesday, August 11, 2009

Perseid Meteor Shower Peaks August 12th, 2009



Every year in early August, we can observe the Perseid meteor shower (“the Perseids”). And it’s a fascinating sky event.

Here’s a beginners’ guide to what it is and how best to enjoy it. (Perhaps, impress your friends with these astronomy questions and answers!)

What are the Perseids and what is a meteor?


Every year in August, the Earth passes through rock and dust fragments left behind by the comet Swift-Tuttle, last time it came near the Sun. As these small particles collide with the Earth’s atmosphere, they burn-up, often creating a startling streak of light across the sky.

You can easily observe this and it can be a wonderous spectacle.



Above: A Perseid fireball photographed August 12, 2006, by Pierre Martin of Arnprior, Ontario, Canada

Why is it called the Perseid meteor shower?

The term “Perseid”, refers to the star constellation of Perseus.

The meteors actually have nothing to do with the stars we see from Earth, as being part of Perseus. It just appears as though the meteors originate from Perseus.

In fact, the rock fragments are close to the Earth – that’s why they burn in our atmosphere.

They are very close, just a few hundred miles – not many, many light years distant like the stars.

But, if you trace-back the bright trails of meteors we see, they appear to originate from the stars of Perseus.

When can you see them?

The Perseid meteor shower actually starts in late July and runs to late August. However, the best time to view is around the peak.

It’s not precise, but the 2009 peak is expected on August 12th at around 15.00 hours UT. There is some uncertainty, so it’s very worthwhile to observe either side of this.

In particular for European observers, the hours of darkness either side the peak hours, may well prove more fruitful! So try the previous Tuesday night, as well as the night of Wednesday 12th.

And there is also a potentially prominent Moon to contend with. It will not set below the horizon until the early hours of the morning.

What equipment do you need to observe the meteor shower?

The good news is none! Just use your eyes.

It will help your observation if you give your eyes some time (say 15 minutes), to become adapted to the darkness.

Binoculars my also help, but on the other hand, they may restrict your view to a small part of the sky.

The meteors originate in the region of Perseus, but they may appear in view just about anywhere in the sky. Although, if you were to track-back their trails, you would get to Perseus.

Can they be measured, at all?

Yes. Keen astronomers count how many appear in a fixed period of time, in a certain area of the sky. This is expressed as a Zenithal Hourly Rate (ZHR).

We may expect around 100 streaks of meteor light across the sky per hour, at or near the shower peak.

Do watch out for them on Wednesday 12th August and during hours of darkness, before and after.