What is an N-Tier application?

Asked

Viewed 4,376 times

10

I’ve always heard a lot about N-Tier applications, but thinking about it lately I’ve been a little confused about what it really means. Searching on Google I found the wikipedia article on the subject and I saw that this has to do with a physical separation.

So in this way, an N-Tier application is an application that is divided into N parts and each one runs in a different environment? Then a web application with access to the database would be considered 3-Tier because it is divided into client, server and database, each of which works in one place?

But in that case if the database server is on the same computer as the web server, would that be 2-Tier? Or what counts is that they are separate processes?

  • I’ve only seen to date the use of Tier to categorize datacenter level

  • 3

    Tier is a layer that represents a logical sequence, period. You can create an application of 1.. N layers, the way you think it’s right. That doesn’t mean it’s something physical or in separate environments. is only the abstract separation of its application.

  • 1

    @Josuéeduardo What you said, with a little more detail, would give a good answer to post down there ;)

  • 3

    Not exactly a duplicate, but there’s a nice response from a guy I’ve never heard of on that topic.

  • It is an approach, but not the only prism that can be considered the layer level of an application.

3 answers

11

Update:

Tier usually refers to physical layer, while layer usually refers to the logical layer. This is an older concept, today basically, most servers run in the cloud, where this "physical separation" does not make much sense. I will treat Tier and Layer as the same word meaning (layer / level)

Tier / Layer is layer that represents a logical sequence, dot. You can create an application of 1.. N layers, the way you think it’s right. That doesn’t necessarily mean it’s something physical or in separate environments. is only the abstract separation of its application in itself. For example nowadays it is well known applications in 3 layers... (not to be confused with MVC).

Just to illustrate:

Tier 1: Presentation layer, where everything is related to view, can be screens of Java Swing, Forms of . Net, or web pages.

Layer 2: Logic Layer. All the specific rules of your application, is the central part of your app. Where in fact you are conceiving your ideas.

Layer 3: Access to the bank. Well here, you... access the bank =). And there may also be some logic related to the transaction, etc.

Nothing prevents you from creating an app with 1,2,3,4 or 5+ layers, for example the 3 cited acimas, another Rest integration, another validation specific and so on. Everything depends on the project requirement. In general 3 is enough or even too.

Why use layers ?

In practice it is to separate the concepts. Generally communication is made through interfaces, which makes it much easier if you need to add or replace one of them. Another situation is when working as a team. Where you have the front guys developing the graphical interface, others in the "core", etc. Where each team does not change the code of the other team, all working on the same project. And at the same time they know what to pass and what to receive from the top/bottom layer by using the interfaces' contracts. All this in the world of POO, other paradgmas I’m not sure how it should work.

Emphasizing that "layer" is the abstract separation of the logic of your project. But when it comes to large architectures, we can also have N layers, at the application level, where each layer can correspond to an application running on a server, which communicates with another one running on another server, a good example of this are commercial applications, where things start to get really big.

In general more layers does not mean better, the more layers, the more decoupling you have, which is good but often unnecessary, but generates greater complexity and maintenance work.

Note which layer has the stack scheme, where to reach the last you must go through all intermediaries, ex:

layer 1 <-> layer 2 <-> layer 3

  • 1

    In fact, "N-Tier" refers rather to the physical separation of concepts and only sporadically an N-Tier system uses no more than a machine in production, because the architecture is all designed to be deployed on more than one machine. Do not confuse "N-Tier" with "Multi Layer", the latter concerns only the logical separation of concepts and not necessarily their physical separation.

  • 1

    If it is really a physical layer it would be interesting to reformulate the answer, if it is logical to put some reference.

  • Highlighting only the information concerning layer x Tier: http://stackoverflow.com/questions/120438/whats-the-difference-between-layers-and-tiers

  • 1

    @Josuéeduardo In other words: "This does not necessarily mean that it is something physical or in separate environments" is a statement incorrect in the case of "tiers".

  • @Caffé Updated the definitions, Thank you

7

A N-Tier application, an n-layered application program, is an application developed to have several logical layers. Each layer is self-contained enough so that the application can be divided into multiple computers in a distributed network.

The most common form of architecture is the three-layer (3-Tier) application, commonly used in web applications, in which the layers are:

  • user interface (Presentation Layer);
  • business logic (Business Layer); and
  • database (Data Layer).

Each layer of this architecture is typically maintained on a specific server to become more scalable and independent of the others. For the same purpose are used middleware technologies such as CORBA, Web Services or RMI.

This architecture has as characteristics:

  • Low cost of availability;
  • Low costs in changing the database;
  • Low costs in changing business logic;
  • Efficient storage and reuse of resources.

It is debatable that counts as "layers", but in my opinion it needs to at least cross the frontier process. Or else it is called layers. But this doesn’t have to be on physically different machines. Although I do not recommend, you can host layers and logical database in the same box.

Exemplo de aplicação 3-tier

One implication is that the presentation layer and the logical layer (sometimes called Business Logic Layer) need to cross borders "by wire" sometimes by unreliable, slow, and / or insecure network. This is very different from simple desktop application, where data resides on the same machine as files or web applications where you can access the database directly.

For n-Tier programming, you need to package the data in some sort of transportable way called the "dataset", and take them along the wire. The . Net Dataset Class or Web Services as SOAP are few of such attempts to "pass" objects along the wire.

  • 1

    Good answer. Some Obs: a) N-Tier refers not only to logical layers but to actual physical layers. b) It will be very difficult for you to find a web application "accessing the database directly"; there are frameworks that handle data access in a very transparent way, but in practice you will always have at least two layers: the web browser and the application server that received the request and returned something (html, json, xml, etc.). And rarely will this application server be managing the database - most of the time it will consume an DBMS (hence: 3-Tiers).

2

N-Tier application is an application whose architecture separates concepts physically. "N-Tier" does not refer to logical or conceptual separation only.

But in this case if the database server is in the same computer that the web server, then it would be 2-Tier? Or what counts is that are separate processes?

In this case it remains 3 layers ("3 tiers") because the concepts of web server and database server are physically separated and this system has been architected to actually be deployed using different servers.

N-Tier architecture has become trivial and very common, so this term is almost out of use. Examples of software that are not N-Tier:

  • Applications developed in Clipper.
  • Applications developed in MS Access (almost always a single layer/Tier).
  • Applications developed in any language that does not use one SGBD or consume another remote service to search for or persist your data (for example a Java application that saves your data in XML or any other file managed by itself and not by another software).

A much more common term nowadays is "Multi-layer", and this yes deals with the logical or conceptual separation of a system, not necessarily implying physical separation.

Updating: added below some reference.

It is important to understand the distinction between "layers" and "tiers". "Layers" describes the logical grouping of functionality and components into a application; while "tiers" describes the physical distribution of functionality and components on servers, computers, networks or remote locations. Although both "layers" and "tiers" use the same name set (presentation, business, services, and data), remember that only "tiers" implies physical separation. It is common allocate more than one "layer" on the same physical machine (same "Tier"). You may think of the term "Tier" as referring to patterns of physical distribution as "2 tiers", "3 tiers" and "n tiers".

Source: Microsoft Application Architecture Guide - Layered Application - Notes.

It is logical that Microsoft did not invent this but is only taking advantage of concepts defined long ago.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.