This is a very important topic to consider when developing an application. Many elements need to be considered when deciding on the architecture of the application, such as performance, scalability and future development issues. When you are deciding on which architecture to use, first decide on which of the three aforementioned elements you think is most valuable -- as some choices you make will impact on others. For example, some choices that boost performance will impact on the scalability or future development of your design, etc.
Here we will talk generally about what n-Tier architecture is, and then we will have a look at different n-Tier architectures you can use to develop ASP.NET applications and issues that arise relating to performance, scalability and future development issues for each one.
Firstly, what is n-Tier architecture? N-Tier architecture refers to the architecture of an application that has at least 3 "logical" layers -- or parts -- that are separate. Each layer interacts with only the layer directly below, and has specific function that it is responsible for.
Why use n-Tier architecture? Because each layer can be located on physically different servers with only minor code changes, hence they scale out and handle more server load. Also, what each layer does internally is completely hidden to other layers and this makes it possible to change or update one layer without recompiling or modifying other layers.
This is a very powerful feature of n-Tier architecture, as additional features or change to a layer can be done without redeploying the whole application. For example, by separating data access code from the business logic code, when the database servers change you only needs to change the data access code. Because business logic code stays the same, the business logic code does not need to be modified or recompiled.
[Note] tier and layer mean the same thing [End Note]
An n-Tier application usually has three tiers, and they are called the presentation tier, the business tier and the data tier. Let's have a look at what each tier is responsible for.
Presentation Layer
Presentation Layer is the layer responsible for displaying user interface and "driving" that interface using business tier classes and objects. In ASP.NET it includes ASPX pages, user controls, server controls and sometimes security related classes and objects.
Business Tier
Business Tier is the layer responsible for accessing the data tier to retrieve, modify and delete data to and from the data tier and send the results to the presentation tier. This layer is also responsible for processing the data retrieved and sent to the presentation layer.
In ASP.NET it includes using SqlClient or OleDb objects to retrieve, update and delete data from SQL Server or Access databases, and also passing the data retrieved to the presentation layer in a DataReader or DataSet object, or a custom collection object. It might also include the sending of just an integer, but the integer would have been calculated using the data in the data tier such as the number of records a table has.
BLL and DAL
Often this layer is divided into two sub layers: the Business Logic Layer (BLL), and the Data Access Layers (DAL). Business Logic Layers are above Data Access Layers, meaning BLL uses DAL classes and objects. DAL is responsible for accessing data and forwarding it to BLL.
In ASP.NET it might be using SqlClient or OleDb to retrieve the data and sending it to BLL in the form of a DataSet or DataReader. BLL is responsible for preparing or processing the data retrieved and sends it to the presentation layer. In ASP.NET it might be using the DataSet and DataReader objects to fill up a custom collection or process it to come up with a value, and then sending it to Presentation Layer. BLL sometimes works as just transparent layer. For example, if you want to pass a DataSet or DataReader object directly to the presentation layer.
Data Tier
Data tier is the database or the source of the data itself. Often in .NET it's an SQL Server or Access database, however it's not limited to just those. It could also be Oracle, mySQL or even XML. In this article we will focus on SQL Server, as it has been proven to be the fastest database within a .NET Application.
Logical Layers vs. Physical Layers (Distributed)
Logical Layers and Physical Layers are the ones that confuse people. Firstly, a logical layer means that layers are separate in terms of assembly or sets of classes, but are still hosted on the same server. Physical layer means that those assemblies or sets of classes are hosted on different servers with some additional code to handle the communication between the layers. E.g. remoting and web services.
Deciding to separate the layers physically or not is very important. It really depends on the load your application expects to get. I think it's worth mentioning some of the facts that might affect your decision.
Please DO note that separating the layers physically WILL slow your application down due to the delay in communicating between the servers throughout the network, so if you are using the physical layer approach, make sure the performance gain is worth the performance loss from this.
Hopefully you would have designed your application using the n-Tier approach. If this is the case, then note that you can separate the layers in the future.
Cost for deploying and maintaining physically separated applications is much greater. First of all, you will need more servers. You also need network hardware connecting them. At this point, deploying the application becomes more complex too! So decide if these things will be worth it or not.
Another fact that might affect your decision is how each of the tiers in the application are going to be used. You will probably want to host a tier on a separate server if more than 1 service is dependent on it, e.g. You might want to host business logic somewhere else if you have multiple presentation layers for different clients. You might also want a separate SQL server if you have other applications using the same data.
Library tutorials & articles
Boosting Your .NET Application Performance
By James Yang, published on 08 Aug 2004
Page 2 of 7
- Introduction
- What is n-Tier Architecture?
- Performance, Scalability and Future Development
- Security
- Class Design
- Data Application Blocks
- Conclusion
What is n-Tier Architecture?
Related articles
Related discussion
-
Using ADO.NET with SQL Server
by Agrapha77 (26 replies)
-
Creating a Generic Site-To-Rss Tool
by vishal01 (6 replies)
-
PictureBox Control
by jared69sib (29 replies)
-
C# Sourcesafe Automation
by rammohan.adduri@gmail.com (3 replies)
-
convert text file to excel
by goral (10 replies)
Related podcasts
-
Microsoft MSDN Videos: New Web Developer features in VS 2010
Published 1 month ago, running time 0h0m
Mike Ormond, from Microsoft's Developer and Platform Group, gives a session on the top 10 items that developers might be interested in learning more about in Visual Studio 2010 and ASP.net.
Related jobs
-
.NET Web and Back End Developer (£1,400 GBP reward)
Ticketer in London, United Kingdom
Depending on experience -
Software Engineer (£480 GBP reward)
Granta Design Ltd in Cambridge, United Kingdom
£30-40k + health/gym + pension + share options -
Senior Web Engineer / Web Developer ($480 USD reward)
Xignite in San Mateo, CA, United States
Competitive with full benefits -
C#/.NET Developer / Scrum Master (£720 GBP reward)
LANDesk in Woking, United Kingdom
£45,000-50,000 GBP per annum
Events coming up
-
Sep
22
An Exceptionally good evening with Phil Winstanley (In person)
Manchester, United Kingdom
If you're waiting around for users to tell you about problems with your website or application, you're only seeing a tiny fraction of all the problems
This thread is for discussions of Boosting Your .NET Application Performance.
A helpful practice I first read about in Advanced Visual Basic 6.0 by the Mandlebrot Set Intl. Ltd. was to store the recordset/dataset/custom collection data in the collection class and make the properties of the contained object point back to a row or item in that set. Saves many, many data operations over time, and thus boosts performance.
-rory 8)
The topic explained is very useful especially for a .Net beginner. Practically these things counts a lot when working on big application\projects.
Hi
Of Course it is a very useful topic from the point of view of an interview also. It provides a great help.
Thanks
Tier and layer do NOT mean the same thing . According to http://codebetter.com/blogs/david.hayden/archive/2005/07/23/129745.aspx
Tier is more about where the code / processes run (physical location), and Layer is more about how the code is logically grouped.
Thanks,
Anmol Gupta
This is one of the BEST article on 3-Tier design.....
Excellent Efforts....
Thanks a lot,
Dattaprasad
Hi, really make sense. good article. n tier tutorial video
!--removed tag-->Hi, really make sense. good article. n tier tutorial video
!--removed tag-->