Wednesday, April 16, 2008

Ajax in .NET (Gaia) - High performance

I have recently worked in a project where we tried out different ajax technologies for .NET in a high performance web site.

The challange is when you want to use postback to post data with ajax in yoyr page. If you don't need the postback functionality, you should probably just go for Jquery og Prototype. If you need the postback on your page you have to select a framework to do the job for you.

1) You could use Jquery og Prototype for this functionality as well, but you will end up coding a lot of javascript by hand and you have to build webservices to recieve the data.

2) You could use the .NET Ajax framework. This will do the job for you, but a big drawback is that the framwork generates a lot of javascript-references (who is not cached by default). This is slow and I would not recommend it.

3) You could use (and in my opinion should use) a library called Gaia. Basicly this library has the same functionality as .NET Ajax, but in the last release you will have the ability to generate the javascript before you deploy the application, and put it on any webserver you want. The reference to the file will go in the end of the body (where you should put all your javascript refereneces).

Thanx to the Gaia-team and the performence-issues we found in our project, our application could handle over 1200 req/sec during a stresstest, as opposed to 70-80 with the .NET ajax! On the same server, and the same code in the application...

If you need postback and end up using Gaia, I would recommend not using JQuery or Prototype by hand. Do all your Ajax-work with Gaia instead.

So my tip - check out Gaia!! http://ajaxwidgets.com/

Don't use DateTime.Parse(), use DateTime.ParseExact() instead

It seems that very few people know that DateTime.Parse() is COM dependent, evil one. Moreover, even in Microsoft.NET, there is no assurance that such string that DateTime.Parse() accepts on your machine is acceptable under other machines. Basically DateTime.Parse() is for newbies who don't mind unpredictable behavior.

Yes,

DateTime.ParseExact (datestr, CultureInfo.CurrentCulture.DateTimeFormat.GetAllDateTimePatterns(), CultureInfo.CurrentCulture);

instead of

DateTime.Parse(datestr);

is quite annoying because of its lengthy parameters. But first thing you should do right now is to prepare your own MyDateTime.Parse() that just returns the same result of the above. It's also true to several culture-dependent String methods (IndexOf, LastIndexOf, Compare, StartsWith, EndsWith - all of them are culture sensitive, even with InvariantCulture) to avoid unexpected matches/comparisons.

http://msdn.microsoft.com/msdnmag/issues/05/03/CultureInfo/default.aspx?side=true#a

Tuesday, April 1, 2008

10 Tips for Writing High-Performance Web Applications

Rob Howard has written a great article on asp.net optimation. This is a MUST READ if you develop web-applications for high performance!

Tip 1—Return Multiple Resultsets
Tip 2—Paged Data Access
Tip 3—Connection Pooling
Tip 4—ASP.NET Cache API
Tip 5—Per-Request Caching
Tip 6—Background Processing
Tip 7—Page Output Caching and Proxy Servers
Tip 8—Run IIS 6.0 (If Only for Kernel Caching)
Tip 9—Use Gzip Compression
Tip 10—Server Control View State

http://msdn.microsoft.com/msdnmag/issues/05/01/ASPNETPerformance/toc.asp