Thursday, September 27, 2007

What is 3- and n-tier architecture


N-Tier Architecture:

N-tier architecture has become a buzzword among serious developers. Simply put, n-tier architecture means carefully separating your application into any number of logical, functional layers. For example, you may
separate your your data, your business logic, and your presentation. This allows your application to be better organized and maintained. It also allows your application to be deployed in a wider variety of ways.

Developing an application using n-tier architecture usually (not always) takes more time, so it is important to identify which level n-tier to use
Easy installation, simple upgrades, and excellent security are only a few of the benefits that come when an application is divided into multiple layers.
As an example, imagine this diagram represents a company with users accessing the application from the office, home, and remotely, using wireless devices. If the company wants to change their application (e.g. use a more powerful database, or add some business logic), they can do so with little effort.
Client-tier-
Is responsible for the presentation of data, receiving user events and controlling the user interface. The actual business logic (e.g. calculating added value tax) has been moved to an application-server. Today, Java-applets offer an alternative to traditionally written PC-applications. See our Internet-page for further information.
Application-server-tier-
application server provides exposes business logic for client applications through various protocols.
Furthermore, the term "component" is also to be found here. Today the term pre-dominantly describes visual components on the client-side. In the non-visual area of the system, components on the server-side can be defined as configurable objects, which can be put together to form new application processes.

Data-server-tier-
This tier is responsible for data storage. Besides the widespread relational database systems, existing legacy systems databases are often reused here.
It is important to note that boundaries between tiers are logical. It is quite easily possible to run all three tiers on one and the same (physical) machine. The main importance is that the system is neatly structured, and that there is a well planned definition of the software boundaries between the different tiers.


Clear Explanation for 2 and 3 –tier architectures with examples:

Let's suppose I'm going to write a piece of software that students at a school can use to find out what their current grade is in all their classes. I structure the program so that a database of grades resides on the server, and the application resides on the client (the computer the student is physically interacting with).

When the student wants to know his grades, he manipulates my program (by clicking buttons, menu options, etc). The program fires off a query to the database, and the database responds with all the student's grades. Now my application uses all this data to calculate the student's grade, and displays it for him.

This is an example of a 2-tier architecture. The two tiers are:

1. Data server: the database serves up data based on SQL queries submitted by the application.
2. Client application: the application on the client computer consumes the data and presents it in a readable format to the student.

Now this architecture is fine.If you've got a school with 50 students. But suppose the school has 10,000 students.Now we've got a problem. Why?

Because every time a student queries the client application, the data server has to serve up large queries for the client application to manipulate. This is an enormous drain on network resources.

So what do we do? We create a 3-tier architecture by inserting another program at the server level. We call this the server application. Now the client application no longer directly queries the database; it queries the server application, which in turn queries the data server.

What is the advantage to this? Well, now when the student wants to know his final grade, the following happens:

1. The student asks the client application.
2. The client application asks the server application.
3. The server application queries the data server.
4. The data server serves up a recordset with all the student's grades.
5. The server application does all the calculations to determine the grade.
6. The server application serves up the final grade to the client application.
7. The client application displays the final grade for the student.

It's a much longer process on paper, but in reality it's much faster. Why? Notice step 6. Instead of serving up an entire recordset of grades, which has to be passed over a network, the server application is serving up a single number, which is a tiny amount of network traffic in comparison.

There are other advantages to the 3-tier architecture, but that at least gives you a general idea of how it works.

Incidentally, this website is a 3-tier application. The client application is your web browser. The server application is the ASP code, which queries the database (the third tier) for the question-and-answer you requested

7 comments:

Unknown said...

Its a very nice article........

Praveen said...

I reckon this article as one of the best stuff i found on net.

Divya said...

one of the best articles,i have read on net regarding n and 2 tire applications...thanks!!!

Unknown said...

Its a very good n important article for those, who want to know about 3-and n-tier architechture on net.my all the best wishes with him..... thanks!

Unknown said...

The best so far. example was a buti. keep it up.

S G said...

Nice article.

Satish Kumar Duggirala said...

Good and Nice Article this is ... :)