For a web application, we can improve system performance in the following respects:
Web Layer
Slim the javascript. Tools do this job by stripping unnecessary white spaces, renaming local variables.
Manage ViewState - remove all the unnecessary view state data. some pages don't need view state, we can turn off this feature.
We also can use platform feature - web servers support gzip to compression the load from client to server back and forth.
Web farm is a system level approach to achieve higher performance. In respect of code, we need to take care of the following two issues:
Use universal session solution by set up database session repository;
Uniform of the ViewState key - view state is encrypted by .net framework - we need to setup the encryption key for each server of the web farm with the same explicit value
Database Layer
In addition to using query optimizer, denormalization and such from the perspective of design matter, use database server provided performance monitor to help finding the bottleneck and improving performance.
Middle Tier
An advised way would be adding trace log to major business methods to catch their execution time and times called, so as to find which the critical component to improve performance.
In addition, parallelize coding by multi-threading, forking web service calls. For example, instead of:
svcA();
svcB();
svcC();
we can do:
svcAAsync();
svcBAsync();
svcCAsync();
then use WaitOne or WaitAny or WaitAll to syncronize (join) the treads.
Using proper memory model in our code is also important. e.g. when a string involves a lot of changes, we should use StringBuilder rather than string data type, because, every time change the value of a string, system will create a new string with the new data and abandon the old one. With StringBuilder, it is much faster because it is a chain of nodes.
No comments:
Post a Comment