In the IT world, software applications are being rapidly developed. Clients, and so employers, are just looking for those teams/individuals who can build up applications rapidly, just bothering to make their application live; but what often happens after an application goes live is that users start to use the application and it doesn’t respond well. At this point, clients start to lose users and business.
To code an application is not a big deal; I believe it can be done by virtually anyone, meaning it is not necessary to have great knowledge or experience. Improving performance of an existing application (especially an one put together rapidly) could be quite risky and could cause many ripple effects. Things must be planned first to avoid horrible results.
The following are a few points that can make a site scalable and reliable; but which may initially slow down development. I believe that overall, when maintenance and future changes are taken into account, total development time would be reduced.
1. Minimize HTTP based Requestss
Problem 1: Serving images - no matter if they are of less than 1 KB - as separate web resources, cause separate web requests to the server, which impact performance.
Solutions:
Use Image Maps to merge up images, though image Maps could only merge up those images which are in sequence, like navigation images, so it depends upon your web site/page design.
Use Inline images. Inline images could increase your HTML page size but would cause fewer requests to the server.
CSS Sprites can also be used to merge up images and setting their position and backgrounds.
Problem 2: Using CSS is very good practice but serving stylesheets as separate resources, thus causing separate requests, should be considered very carefully.
Solutions:
Try your best to combine all your CSS based classes into a single .css file as lot of .css files will cause a large amount of requests, regardless of the file sizes.
.css files are normally cached by browsers, so a single and heavy .css file doesn’t cause a long wait on each page request.
Inline .css classes could make HTML heavy, so again: go ahead with a single.css file.
Problem 3: JavaScript is an awesome scripting language which can be quite powerful to play with. Nonetheless, it should be used carefully not only for request size issues; but also because it can have a way of causing unpredictable performance issues.
Solution: Inline JavaScript could make the HTML page heavy, so it’s preferred to serve separate .js files or a single JavaScript file to keep all JavaScript-based scripts in a single place.
JavaScript files also get cached automatically by browsers, so they usually aren’t requested each time the page is loaded by the browsers.
2. HTTP Compression
HTTP Compression is used to compress contents from the web server. HTTP requests and responses could be compressed, which can result in great performance gains. Through HTTP compression, the size of the payload can be reduced by about 50%, which is great. Isn’t it?
HTTP Compression is now widely supported by browsers and web servers.
If HTTP compression is enabled on the web server, and if the request header includes an Accept-Encoding: gzip, deflate header, the browser supports gzip and deflate compression mechanisms, so the response can be compressed in any of the given formats by the web server in order to reduce the payload size. This leads to an increase in performance. Latter that compressed response is decompressed by the browser and rendered normally.
Following are very good links which detail HTTP Compression and their implementations:
Click here to get detailed knowledge on HTTP compression.
Click here to learn how to enable HTTP compression in IIS.
3. Correct Formatted Images at the Right Place
Problem: Normally designers use JPG or GIF formats quite randomly and ignore some other good formats to compress images.
Solution: Correct format should be used for right purpose like
If you have to place a background image, some large image or a screenshot then the suggested format is JPG/JPEG.
If you have to use small graphics like button images, header images, footer images, navigation bar images or clip arts, then the suggested format is PNG.
If an image is not required to be in high or true colors and 256 colors are enough, then GIF is preferred.
4. Compress CSS, JavaScript and Images
CSS files (.css), images and JavaScript (.js) files can be compressed, as normally .css and .js files contain unnecessary spaces, comments, unnecessary code and such other things. A number of high quality (and free) utilities are available to help you pre-compress your files.
Following are a few good links for such utilities:
Compress PNG images by clicking here
Compress JPG images by clicking here
Compress .CSS files by clicking here and here and here
Compress .Js files by clicking here and here and here
I have used these utilities and seen compression results of about 50% in file size reduction after using such loss-less compression, so I recommend them.
5. CSS at Top
The recommended approach is to put CSS links on top of the web page, as it makes the page render progressively efficient. Since users want to see the contents of a page whilst it’s loading rather than white spaces, contents/formats should be given on top. HTML Specifications clearly say to declare style sheets in the head section of a web page.
6. Javascript at Bottom
When scripts are defined on top of the page they can take unnecessary time to load; they don’t show the contents that users are expecting after making any request to an HTTP web server. It's better to display a the HTML contents of a page, then load any scripting code (when possible, of course).
Preferably use/link up JavaScript-based scripts at the bottom of a web page. Alternatively you can use the defer attribute, which runs the script at the end of page loading, but that is not the preferable approach as it is not browser independent. For example, Firefox doesn’t support it and could mess up with document.write, so only use it once you fully understand the implications.
7. Content Delivery Network: (CDN)
When a browser makes a request to any web page – that is, he types a URL/URI of any web page or web site, a request goes through many hops (routers and computers) and then finally reaches its final destination. This happens both for requests and responses. This operation affects performance and can severely effect load time.
A Content Delivery Network implies a collection of computers, distributed all over the world, which deliver data (contents). Through a CDN you can have your website data on multiple servers distributed in different locations around the world. Distribute web application data in different places around the world so request can be served from the nearest location and save time (which means performance and money as well).
8. Ajax
Problemm: Ajax is being increasingly used to improve usability, but oftentimes in a way which increases overall server load.
Solutions:
Preferably use the GET method for Ajax based Requests, because if you use POST method then the request header would be sent first, followed by the data, which basically splits the request in two steps. A single-step request can be achieved with GET if a cookie is not too long and the URL is not larger than 2k.
When using ASP.NET AJAX and the UpdatePanel control for partial page rendering, use the maximum number of update panels to update small chunks of page, but use them wisely. Don’t set the Update property to Always unless needed. Instead, set the update mode to Conditional, otherwise all the partial chunks would be sent together after each asynchronous postback.
Ajax based requests can also be cached when using the GET method. If the URL is the same, then cached data can be used from the client, and a round trip to the server can be avoided.
9. Ajax vs. Callback
Problem: Ajax is a great solution for asynchronous communication between client (web browser) and HTTP servers, but one solution can't be applied to every problem. This means that Ajax is great mechanism for sending requests to the server without making a full page postback, but what if you need to send a request to the server and don’t even need partial rendering?
Solution: best solution is Callback.
For example, if you need to check whether a user exists or not, or if a user has forgotten his/her password and you just need to send a request to the server to check if user name exist, there is no need for client-side render - just a server side operation.
Following are a couple of great links which explain callbacks: Please click here and here.
10. Reduce Cookie size
Cookies are stored on the client side to keep information about users (authentication and personalization). Since HTTP is a stateless protocol, cookies are common in web development to maintain information and state. Cookies are sent with every HTTP requests, so try to keep them low in size to minimize effects on the HTTP response.
Cookie’s size should be minimized as much as possible.
Cookies shouldn’t contain secret information. If really needed, that information should be either encrypted or encoded.
Try to minimize the number of cookies by removing unnecessary cookies.
Cookies should expire as soon as they become useless for an application.
11. Use Cache appropriately
Cache mechanism is a great way to save server round trips - and also database server round trips - as both round trips are expensive processes. By caching data we can avoid hitting them when unnecessary. Following are few guidelines for implementing caching::
Static contents should be cached, like “Contact us” and “About us” pages, and such other pages which contain static information.
If a page is not fully static, it contains some dynamic information. Such pages can leverage the ASP.NET technology, which supports partial page caching.
If data is dynamically accessed and used in web pages - like data being accessed from some file or database - and even if data is consistently or regularly changed, then that data could be cached by using ASP.NET 2.0 cache dependency features. As soon as data changes from the back-end by some other means, the cache would be updated.
Now that web technologies such ASP.NET have matured and offer such great caching capabilities, there's really no reason not to make extensive use of them.
Following are few very good links to implement caching for different types of data (static and dynamic):
Click here to cache Full page (static page caching).
Click here and here to cache partial page caching.
Click here to cache dynamic data with dependency.
12. Upload compiled code rather than source code
Pre-compiled ASP.NET pages perform much better than source code versions. Actually pre-compilation give web sites a performance boost especially when the first request is made to a folder containing that resource.
Uploading a pre-compiled version boosts up performance since the server doesn’t need to compile a page at request-time.
13. Conclusions
Following are few good practices to gain better performance::
For HTTP compression, GZip is considered the most effective and most popular by means of browsers and HTTP server. It can reduce file size up to 70% in size.
Always keep JavaScript and CSS in external files.
Avoid redirects until needed. Server.Transfer is also provided so consider that as well since it performs better in some conditions.
Minimize use of Iframes as it's costly.
Avoid try-catch blocks for control-flow as they perform poorly. Exceptions should be used only in truly exceptional situations.
Minimize Cookie/CSS sizes.
Minimize DOM objects on page as they are heavy weight.
Use link tags rather than @import to use/link up CSS.
Favicon, being a static image displayed in the browser’s address bar, should be cacheable and compressed.
Always prefer a cache-friendly folder structure. For example, create specific folders for static contents, like /static for static images/static pages…
SSL can never be cached so minimize its usage. Keep it for those pages which need to be secure, rather than using it for all the pages.
HTTP Post requests can’t be cached, so choose the HTTP method appropriately.
Prevent Denial of Service (Dos) attacks. Recommended article here.
Prevent SQL Injection. Recommended article here.
Prevent Cross Site Scripting (XSS). Recommended article here.
I hope you have learned some very good approaches and techniques to keep your web application in good shape on an HTTP server. I personally don’t think any are flat-out ignorable nor is any too difficult to implement.
As performance is a vital part of success for any web application, I have tried to be as general as possible, so every web technology (ASP.NET, asp, php, jsp, jsf and so on) can follow these tips.
Tuesday, August 26, 2008
ASP.NET Tip: Keep hidden files hidden
I have seen a few cases of this so I wanted to let everyone know. If you install the FrontPage Server Extensions (FPSE) on a web server, it will install some configuration files in a directory under your web site called _vti_cnf. This folder contains a bunch of files that FPSE use to update files and perform the various tasks that it needs to do.
The problem comes if that _vti_cnf folder is not marked hidden. If something keeps that from happening, you can get a few different errors because of it. The reason is that the aspnet_compiler.exe will try to compile these files since the folder isn't hidden. There is a web.config file in there that will cause an error like:Invalid token 'Text' at root level of document.
XML document must contain a root level element.
Data at the root level is invalid. Line 1, position 1.
As long as this folder is hidden, the compiler will just skip over it and everything will be fine.
So the main thing to remember is that if you install FPSE and suddenly start getting errors, checking if that folder is marked hidden is a great place to start.
The problem comes if that _vti_cnf folder is not marked hidden. If something keeps that from happening, you can get a few different errors because of it. The reason is that the aspnet_compiler.exe will try to compile these files since the folder isn't hidden. There is a web.config file in there that will cause an error like:Invalid token 'Text' at root level of document.
XML document must contain a root level element.
Data at the root level is invalid. Line 1, position 1.
As long as this folder is hidden, the compiler will just skip over it and everything will be fine.
So the main thing to remember is that if you install FPSE and suddenly start getting errors, checking if that folder is marked hidden is a great place to start.
Thursday, July 17, 2008
History Of UML
After Rational Software Corporation hired James Rumbaugh from General Electric in 1994, the company became the source for the two most popular object-oriented modeling approaches of the day: Rumbaugh's OMT, which was better for object-oriented analysis (OOA), and Grady Booch's Booch method, which was better for object-oriented design (OOD). Together Rumbaugh and Booch attempted to reconcile their two approaches and started work on a Unified Method.
They were soon assisted in their efforts by Ivar Jacobson, the creator of the OOSE method. Jacobson joined Rational in 1995, after his company, Objectory, was acquired by Rational. The three methodologists were collectively referred to as the Three Amigos, since they were well known to argue frequently with each other regarding methodological preferences.
In 1996 Rational concluded that the abundance of modeling languages was slowing the adoption of object technology, so repositioning the work on a Unified Method, they tasked the Three Amigos with the development of a non-proprietary Unified Modeling Language. Representatives of competing Object Technology companies were consulted during OOPSLA '96, and were won over by Rumbaugh's a cappella rendition of his version of Joni Mitchell's "Clouds"[citation needed], indicating the victory of his OMT notation of using boxes for representing classes over Grady Booch's Booch method's notation that used cloud symbols.
Under the technical leadership of the Three Amigos, an international consortium called the UML Partners was organized in 1996 to complete the Unified Modeling Language (UML) specification, and propose it as a response to the OMG RFP. The UML Partners' UML 1.0 specification draft was proposed to the OMG in January 1997. During the same month the UML Partners formed a Semantics Task Force, chaired by Cris Kobryn and administered by Ed Eykholt, to finalize the semantics of the specification and integrate it with other standardization efforts. The result of this work, UML 1.1, was submitted to the OMG in August 1997 and adopted by the OMG in November 1997[1].
As a modeling notation, the influence of the OMT notation dominates (e. g., using rectangles for classes and objects). Though the Booch "cloud" notation was dropped, the Booch capability to specify lower-level design detail was embraced. The use case notation from Objectory and the component notation from Booch were integrated with the rest of the notation, but the semantic integration was relatively weak in UML 1.1, and was not really fixed until the UML 2.0 major revision.
Concepts from many other OO methods were also loosely integrated with UML with the intent that UML would support all OO methods. For example CRC Cards (circa 1989 from Kent Beck and Ward Cunningham), and OORam were retained. Many others contributed too with their approaches flavoring the many models of the day including: Tony Wasserman and Peter Pircher with the "Object-Oriented Structured Design (OOSD)" notation (not a method), Ray Buhr's "Systems Design with Ada", Archie Bowen's use case and timing analysis, Paul Ward's data analysis and David Harel's "Statecharts", as the group tried to ensure broad coverage in the real-time systems domain. As a result, UML is useful in a variety of engineering problems, from single process, single user applications to concurrent, distributed systems, making UML rich but large.
The Unified Modeling Language is an international standard:
ISO/IEC 19501:2005 Information technology — Open Distributed Processing — Unified Modeling Language (UML) Version 1.4.2.
UML has matured significantly since UML 1.1. Several minor revisions (UML 1.3, 1.4, and 1.5) fixed shortcomings and bugs with the first version of UML, followed by the UML 2.0 major revision that was adopted by the OMG in 2003. There are four parts to the UML 2.x specification: the Superstructure that defines the notation and semantics for diagrams and their model elements; the Infrastructure that defines the core metamodel on which the Superstructure is based; the Object Constraint Language (OCL) for defining rules for model elements; and the UML Diagram Interchange that defines how UML 2 diagram layouts are exchanged. The current versions of these standards follow: UML Superstructure version 2.1.2, UML Infrastructure version 2.1.2, OCL version 2.0, and UML Diagram Interchange version 1.0[2].
Although many UML tools support some of the new features of UML 2.x, the OMG provides no test suite to objectively test compliance with its specifications.
They were soon assisted in their efforts by Ivar Jacobson, the creator of the OOSE method. Jacobson joined Rational in 1995, after his company, Objectory, was acquired by Rational. The three methodologists were collectively referred to as the Three Amigos, since they were well known to argue frequently with each other regarding methodological preferences.
In 1996 Rational concluded that the abundance of modeling languages was slowing the adoption of object technology, so repositioning the work on a Unified Method, they tasked the Three Amigos with the development of a non-proprietary Unified Modeling Language. Representatives of competing Object Technology companies were consulted during OOPSLA '96, and were won over by Rumbaugh's a cappella rendition of his version of Joni Mitchell's "Clouds"[citation needed], indicating the victory of his OMT notation of using boxes for representing classes over Grady Booch's Booch method's notation that used cloud symbols.
Under the technical leadership of the Three Amigos, an international consortium called the UML Partners was organized in 1996 to complete the Unified Modeling Language (UML) specification, and propose it as a response to the OMG RFP. The UML Partners' UML 1.0 specification draft was proposed to the OMG in January 1997. During the same month the UML Partners formed a Semantics Task Force, chaired by Cris Kobryn and administered by Ed Eykholt, to finalize the semantics of the specification and integrate it with other standardization efforts. The result of this work, UML 1.1, was submitted to the OMG in August 1997 and adopted by the OMG in November 1997[1].
As a modeling notation, the influence of the OMT notation dominates (e. g., using rectangles for classes and objects). Though the Booch "cloud" notation was dropped, the Booch capability to specify lower-level design detail was embraced. The use case notation from Objectory and the component notation from Booch were integrated with the rest of the notation, but the semantic integration was relatively weak in UML 1.1, and was not really fixed until the UML 2.0 major revision.
Concepts from many other OO methods were also loosely integrated with UML with the intent that UML would support all OO methods. For example CRC Cards (circa 1989 from Kent Beck and Ward Cunningham), and OORam were retained. Many others contributed too with their approaches flavoring the many models of the day including: Tony Wasserman and Peter Pircher with the "Object-Oriented Structured Design (OOSD)" notation (not a method), Ray Buhr's "Systems Design with Ada", Archie Bowen's use case and timing analysis, Paul Ward's data analysis and David Harel's "Statecharts", as the group tried to ensure broad coverage in the real-time systems domain. As a result, UML is useful in a variety of engineering problems, from single process, single user applications to concurrent, distributed systems, making UML rich but large.
The Unified Modeling Language is an international standard:
ISO/IEC 19501:2005 Information technology — Open Distributed Processing — Unified Modeling Language (UML) Version 1.4.2.
UML has matured significantly since UML 1.1. Several minor revisions (UML 1.3, 1.4, and 1.5) fixed shortcomings and bugs with the first version of UML, followed by the UML 2.0 major revision that was adopted by the OMG in 2003. There are four parts to the UML 2.x specification: the Superstructure that defines the notation and semantics for diagrams and their model elements; the Infrastructure that defines the core metamodel on which the Superstructure is based; the Object Constraint Language (OCL) for defining rules for model elements; and the UML Diagram Interchange that defines how UML 2 diagram layouts are exchanged. The current versions of these standards follow: UML Superstructure version 2.1.2, UML Infrastructure version 2.1.2, OCL version 2.0, and UML Diagram Interchange version 1.0[2].
Although many UML tools support some of the new features of UML 2.x, the OMG provides no test suite to objectively test compliance with its specifications.
Wednesday, July 16, 2008
Inflation at 5.5% in 6 months: RBI
The economy’s woes due to double-digit inflation are unlikely to end any time soon and while the Reserve Bank of India will hold a review meeting around July-end, the central bank is unable to offer any assurances on interest rate cuts in the near future. The central bank hopes that its strategies will help keep growth at 8% and bring down inflation to 5.5% in six months, but much depends on international factors, RBI governor Y V Reddy told the standing committee attached to the finance ministry on Monday in a briefing that lasted more than three hours. Reflecting their political worries, MPs questioned Reddy on the efficacy of high interest rates which had led to incease in the home loan outstandings and tenures. Reddy was not able to clearly say when the trend could be reversed or even if more hikes could be ruled out. He defended the economic situation as not being as bad as that of other growing economies. He pointed out that the “world economy was in stagflation” which was bound to cast a shadow on India as well. But on the other hand, it was incorrect to compare India with developed European nations or Japan.
A couple of MPs argued that while FDI was being allowed into the stock market, there were disincentives for Indian capital in view of the anti-inflationary measures that government had taken. This amounted to FDI being favoured even though the RBI’s response is clearly aimed at checking demand. Reddy said RBI measures had sucked out a large amount of liquidity from the economy and perhaps more measures were needed to check inflation.
A couple of MPs argued that while FDI was being allowed into the stock market, there were disincentives for Indian capital in view of the anti-inflationary measures that government had taken. This amounted to FDI being favoured even though the RBI’s response is clearly aimed at checking demand. Reddy said RBI measures had sucked out a large amount of liquidity from the economy and perhaps more measures were needed to check inflation.
India will launch 3G Soon
After a long wait, the Indian government has decided that it will auction 3G spectrum, and will allow foreign players to participate in the bidding. The spectrum is going to be released in the 2100 MHz band, which would make it compatible with rest of the world, barring a few countries such as the U.S.
Here are some specifics:
Winners will be required to pay 0.5 percent of total adjusted gross revenue to the state on an annual basis for the first three years of operation, rising to 1 percent thereafter.
Winners will not be allowed to trade or resell the spectrum and they will not be allowed to merge in the first five years after the grant.
About 30MHz of spectrum will be sold in total.
India will also auction licenses for broadband wireless (WiMAX) services, with the reserve price fixed at 25 percent of the amount for 3G spectrum.
The spectrum is going to be plentiful; our sources say that it will be enough to accommodate six carriers. The carriers we expect will make it to the finish line include the current leader, Bharti Airtel; Idea Telecom; Reliance and Vodafone (VOD). The two international cell phone companies likely to win the spectrum bid include AT&T (T) and Sistema.
If the rollout of voice services over past decade is any indication, this is a big opportunity for equipment makers. Ericsson (ERICY) and Nokia (NOK) have done well in India, and there is little reason why the situation would change, though one suspects the Chinese equipment vendors are going to act as deflationary counterweights to their Western counterparts.
The 3G services in India will eventually have to compete with WiMAX, which is being seen as the wireless broadband technology of choice by lawmakers. More importantly, this auction is a way for the Indian government to keep the telecom sector specifically and the economy overall growing at a healthy clip. India’s economy was catalyzed by telecom and call center businesses, then spread to other sectors.
Here are some specifics:
Winners will be required to pay 0.5 percent of total adjusted gross revenue to the state on an annual basis for the first three years of operation, rising to 1 percent thereafter.
Winners will not be allowed to trade or resell the spectrum and they will not be allowed to merge in the first five years after the grant.
About 30MHz of spectrum will be sold in total.
India will also auction licenses for broadband wireless (WiMAX) services, with the reserve price fixed at 25 percent of the amount for 3G spectrum.
The spectrum is going to be plentiful; our sources say that it will be enough to accommodate six carriers. The carriers we expect will make it to the finish line include the current leader, Bharti Airtel; Idea Telecom; Reliance and Vodafone (VOD). The two international cell phone companies likely to win the spectrum bid include AT&T (T) and Sistema.
If the rollout of voice services over past decade is any indication, this is a big opportunity for equipment makers. Ericsson (ERICY) and Nokia (NOK) have done well in India, and there is little reason why the situation would change, though one suspects the Chinese equipment vendors are going to act as deflationary counterweights to their Western counterparts.
The 3G services in India will eventually have to compete with WiMAX, which is being seen as the wireless broadband technology of choice by lawmakers. More importantly, this auction is a way for the Indian government to keep the telecom sector specifically and the economy overall growing at a healthy clip. India’s economy was catalyzed by telecom and call center businesses, then spread to other sectors.
Monday, January 21, 2008
Subscribe to:
Posts (Atom)