Archive for 2011/05 - 2011/06
This answers following questions:
- How to improve performance?
- Should I ever use Threading in ASP.NET?
How to improve performance of an ASP.NET MVC page that calls a database which takes a specific amount of time, and the results are then rendered on to an html page? This means, for instance, if 4 method calls takes 4 seconds, then target is, to improve the performance to 2 seconds for 4 database calls.
Takes exactly 3 seconds.
Move it inside a web service, and then call:
Define a handler:
Lets call it async'ly:
Takes ~1 second.
The I/O thread(completion ports or IOCPs) use the ThreadPool, but they use IOCP, which do not interfere with ASP.NET requests. Therefore, you can safely use the asynchronous call to a web service, and update the page accordingly; for instance using UpdatePanel.
These web service asynchronous calls, uses IOCP behind the scenes, freeing ASP from essentially all of the burdens.
I could have done it using the thread pool as well?!
Usually, unless we want to parallelize a CPU-intensive operation in order to get it done faster, it is generally *not recommended* to use a worker thread; this eventually will starve the ThreadPool in an ASP.NET process by queuing too many work items.
Don't forget that you also use Reactive Framework in your ASP.NET app to do the job async'ly.
Takes ~1 second.
I did not delve into the discussion of what Silverlight is and what jQuery is. I just presented the solution, using jQuery for lightweight UI's, Silverlight if its intranet based.
First, please understand that Silverlight is not Macromedia Flash. It is far more superior, and elegant; -- and -- it has the "capabilities" of Flash.
Silverlight and jQuery "may be" intended for similar things, rich user interface, but Silverlight has a complete framework that utilizes the power of .NET and provide rich feature set.
Actually comparing jQuery and Silverlight feels like comparing a red-apple with one-hundred-acre'd-fruit-farm.
Ok, that may be indigestible example, but that's how it really is.
So, how can you compare the two?
Also, you can use jQuery inside Silverlight app, but you cannot otherwise.
The only problem is that, Silverlight requires to be downloaded, similar to Macromedia Flash plugin, but once you download it, you're good to go. Plus, with MEF(Microsoft Extensibility Framework) it feels cool to "componentize" a Silverlight app and load modules on-the-fly and on-demand.
So, must if you choose between the two, go for jQuery if you are considering a web based line of business - lightweight and simple;
And if its a web application, which means, intranet based application for some corporate customer, you can always play with the Silverlight and its features. It can help providing native windows application on the web.
The questions that may help you reach a decision:
0. What feature set customer is looking for? What domain does it belong to? For instance, for a media company you might choose Silverlight UI for a web based app, rather than a jQuery.
1. Is your customer ok with Silverlight requirement on every pc of the network? This means, application will not work if the user has not installed Silverlight.
2. If your customer wants an extra-ordinary user experience; which includes rich interactive media, games, simulation, etc.
Here is an interesting answer posted; and if you’re a jQuery fan this will soothe your veins.
Enjoy, the silver light (0;