The terms tier and layer are frequently used interchangeably, but actually there is a difference between them: Tiers indicate a physical separation of components, which may mean different assemblies such as DLL, EXE etc on the same server or multiple servers; but layers refers to a logical separation of components, such as having distinct namespaces and classes for the Database Access Layer (DAL), Business Logic Layer (BLL) and User Interface Layer (UIL). Therefore, tier is about physical separation and units of deployment, and layers are about logical separation and units of design.

Creating a multi tier project design is more suitable and advisable to mid to large-size projects, whereas a good multi-layered design is suitable for small to mid-size projects.

Let’s understand this difference more closely with my earlier posts on “Developing 3 Tier Application in .NET 2.0”. In reality this example is 3-layer architecture because all the layers are logically separated but stay in one code. Following are the namespaces of each layer

1. Vishwa.Example.Data
2. Vishwa.Example.Business
3. Vishwa.Example.WebSite1


The final DLL contains all the above layers: Vishwa.Example.WebSite1

Now, let’s think how to build the same project in true 3-tier architecture. For simple understanding, each layer will be moved to a separate project and thus creating following three dlls. These dlls can stay on the same machine or different servers.

1. Vishwa.Example.Data.dll     --- see  Data Transfer Objects (DTO) - Data Access Layer
2. Vishwa.Example.Business.dll --- see Data Transfer Objects (DTO) - Business Layer
3. Vishwa.Example.WebSite1.dll  -- Now you can refer the above new dlls to perform the same operation


But, by just moving the code of each layer into a separate project will not work, because first and foremost issue is: each layer depends on other layer, so you can not compile one project without other one and here you are in catch 22 situation.

So you will require changes into current design. Also, if you are not planning to keep all the layers in the same folder of your application, then another big issue- how to refer and communicate with each layer’s object. Here is some approach you can take for each layer to convert into a tier model.

  • Literally, create a separate project for each layer.
  • For Database Access Layer and Business Logic Layer ASP.NET Web Services or .NET Remoting can be used. If you can use .NET 3.0 Windows Communication Foundation (WCF) Services, that will be great, they seem to me like Web Services but more powerful, secure and flexible than Web Services.
  • User Interface Layer will stay as ASP.NET Web Site but some changes will be required for invoking or calling Business Objects. However, existing BLL and DAL layers will be removed from current project.
  • Additionally, I will recommend using Microsoft Enterprise Library - Application Blocks for .NET 2.0. This library can help you to build a robust application, it provides solutions to common development challenges such as data access, logging and user interface etc. You can find more information at http://msdn.microsoft.com/practices
  • By using (Web) Services, you will move one step towards Service Oriented Architecture (SOA), which is becoming more popular now in enterprise application development.
You must be wondering why did I use the word 3-Tier instead of 3-layer?

First of all most of the time people are searching on key words like 3-Tier rather 3-Layer. Word 3-tier architecture is most frequently used but heavily misused in IT industry. So it is easier to bring people to the information they are looking for and then educate them as what exactly it means.

Needless to say that it was easier for me to take a simple example for 3- layer architecture design and explain each layer step by step. Developing a true multi tier approach may look like over killing of the sample project. I may write one sometime in future:).
Signature

Comments

10/23/2007 9:16:50 AM #

Hemant

First of all I would like to thank you for the very nice article.
You have recommended to use Microsoft Enterprise Library because it provides common development challenges.
I appritiate that and I am preaparing to use Microsoft Enterprise Library 3.1 but what are the licencing issues,
can I distribute the Assemblies along with my application?
Can I extend the methods in the Enterprise Library 3.1?

Waiting for your reply.

Hemant India

10/23/2007 9:22:37 AM #

Hemant

Very Nice article.
I am using the same concept of Tiered architecture.

Hemant India

7/12/2009 2:39:11 PM #

virender

hi,

First of all thanks for your article. on internet most of articles on n-layer & n-tier describe same n-layer design BBL,DAL,DTO,Presentation Layer.
but no articles about "N-tier Architecture-Physical separation of components on multiple server". My problem.

Our Team developed a project with following n-layer with one solutions project. currently application running on one web server. but on that portal   4000-5000 user access their accounts information in one time and day by day portal performance decreasing due to user increase. so,  we need increase performance . Currently using following layer.

1. Presentation layer
2. Business Layer
3. Data Transfer object
4. Data Access Layer

For good performance we need physical separation of components on multiple server . It it possible or not ? If possible then how  or it is better way. please help me.

Presentation layer, - Server1

Business Layer ,
Data Transfer object(DTO)- Server2
(Serialazable)

Data Access Layer - Server3

Sql Server 2008 – Server4
(Database Server already running on separate server)

virender India

7/13/2009 2:47:55 AM #

Vishwa

Yes, separation of each layer is possible with cost of serialization/de-serialization and network latency.  What I would suggest you to add a service layer in front of Business Layer. Keep your layer 2 and 3 together in same tier along with business layer so that performance will be less affected in data transfer between layer 2 and 3. For cleanness, you may opt keeping each layer in diff assembly but physically together in one tier.
Let’s say you have an App Server containing all the business objects, which will be accessed through one or more WCF Service.  Now you can use the WCF Service through multiple protocols as it suits your need with any kind of presentation layer. If you ever required exposing any method to a web service you can do that using same business objects.
Please keep in mind, every tier you add will negatively impact your performance, but positively affect your security concerns if properly designed.  I think 3 tiers will be sufficient to handle the load and you may be able to scale up as well as scale out with this design.

Vishwa United States

Add comment


(Will show your Gravatar icon)

  Country flag

biuquote
  • Comment
  • Preview
Loading



About Me

Me Hello,my name is Vishwa Mohan Kumar.
I am a Software Architect. This blog is result of my experiments.

Flickr Photos

Calendar

<<  March 2010  >>
MoTuWeThFrSaSu
22232425262728
1234567
891011121314
15161718192021
22232425262728
2930311234

View posts in large calendar

Recent Comments

Comment RSS

Live Traffic Feed