199

I've seen quite a few developer job postings recently that include a sentence that reads more or less like this: "Must have experience with N-Tier architecture", or "Must be able to develop N-Tier apps".

This leads me to ask, what is N-Tier architecture? How does one gain experience with it?

2
  • 2
    Interesting that this other post is also asking what N-Tier architecture is, but the answers are completely different. stackoverflow.com/questions/7271165/…. Seems there's N-Tier architecture for software and N-Tier architecture for hardware.
    – Noremac
    Commented Aug 28, 2014 at 12:45
  • Related - Onion architecture
    – RBT
    Commented May 13 at 5:14

14 Answers 14

251

Wikipedia:

In software engineering, multi-tier architecture (often referred to as n-tier architecture) is a client-server architecture in which, the presentation, the application processing and the data management are logically separate processes. For example, an application that uses middleware to service data requests between a user and a database employs multi-tier architecture. The most widespread use of "multi-tier architecture" refers to three-tier architecture.

It's debatable what counts as "tiers," but in my opinion it needs to at least cross the process boundary. Or else it's called layers. But, it does not need to be in physically different machines. Although I don't recommend it, you can host logical tier and database on the same box.

alt text
(source: wikimedia.org)

Edit: One implication is that presentation tier and the logic tier (sometimes called Business Logic Layer) needs to cross machine boundaries "across the wire" sometimes over unreliable, slow, and/or insecure network. This is very different from simple Desktop application where the data lives on the same machine as files or Web Application where you can hit the database directly.

For n-tier programming, you need to package up the data in some sort of transportable form called "dataset" and fly them over the wire. .NET's DataSet class or Web Services protocol like SOAP are few of such attempts to fly objects over the wire.

6
  • 7
    "3-tiers" and "N-tiers" is there a difference?
    – chakrit
    Commented Nov 23, 2008 at 8:05
  • 7
    It depends on how you count "tiers" (logical, physical, etc), but you can easily have more than 3 process involved to write an app. UI, UI platform (like Eclipse RCP), Web Services, BLL, DAL, Database, Authentication Services, Reporting Services, Analytical Services... Commented Nov 23, 2008 at 8:12
  • 7
    @chakrit: In my time (I'm old) more that 2-tiers (client-server) was automatically referring to n-tier. Commented Jan 15, 2010 at 17:58
  • 2
    @EugeneYokota - it is said that tiers are to represent physical sections in the architecture (which may or may not be further patitioned, e.g. in a cluster), and layers will refer to the logical grouping of the application components. Commented Apr 3, 2014 at 19:58
  • I have been told something that looks very similar but with the tiers being presentation tier - service tier - integration/data tier. Do you know if these are just different words for the same thing as the architecture shown above or something different? As far as my knowledge goes, they seem the same but I would like to make sure. Commented Aug 16, 2016 at 15:33
20

It's based on how you separate the presentation layer from the core business logic and data access (Wikipedia)

  • 3-tier means Presentation layer + Component layer + Data access layer.
  • N-tier is when additional layers are added beyond these, usually for additional modularity, configurability, or interoperability with other systems.
3
  • 12
    actually if one of those tiers is hosted by a remote party, for instance a payment processor, that tier may not be so "unnecessary"
    – Zak
    Commented Mar 30, 2009 at 17:45
  • 1
    Hmm. There's a huge difference between 'layers' and 'services'. N-Tier is usually used to indicate that for the given tier, anything above it must pass through it to access lower level services. If they are in parallel, I would call them services rather than tiers.
    – Dak
    Commented Jan 16, 2016 at 16:05
  • When constructing the usual MCV (a 3-tier architecture) one can decide to implement the MCV with double-deck interfaces, such that one can in fact replace a particular tier without having to modify even one line of code. We often see the benefits of this, for instance in scenarios where you want to be able to use more than one database (in which case you have a double-interface between the control and data-layers). When you put it on the View-layer (presentation), then you can (hold on!!) replace the USER interface with another machine, thereby automate REAL input (!!!) Commented May 1, 2017 at 19:50
17

It's a buzzword that refers to things like the normal Web architecture with e.g., Javascript - ASP.Net - Middleware - Database layer. Each of these things is a "tier".

4

N-tier data applications are data applications that are separated into multiple tiers. Also called "distributed applications" and "multitier applications," n-tier applications separate processing into discrete tiers that are distributed between the client and the server. When you develop applications that access data, you should have a clear separation between the various tiers that make up the application.

A typical n-tier application includes a presentation tier, a middle tier, and a data tier. The easiest way to separate the various tiers in an n-tier application is to create discrete projects for each tier that you want to include in your application. For example, the presentation tier might be a Windows Forms application, whereas the data access logic might be a class library located in the middle tier. Additionally, the presentation layer might communicate with the data access logic in the middle tier through a service such as a service. Separating application components into separate tiers increases the maintainability and scalability of the application. It does this by enabling easier adoption of new technologies that can be applied to a single tier without the requirement to redesign the whole solution. In addition, n-tier applications typically store sensitive information in the middle-tier, which maintains isolation from the presentation tier.

Taken from Microsoft website.

4

If I understand the question, then it seems to me that the questioner is really asking "OK, so 3-tier is well understood, but it seems that there's a mix of hype, confusion, and uncertainty around what 4-tier, or to generalize, N-tier architectures mean. So...what's a definition of N-tier that is widely understood and agreed upon?"

It's actually a fairly deep question, and to explain why, I need to go a little deeper. Bear with me.

The classic 3-tier architecture: database, "business logic" and presentation, is a good way to clarify how to honor the principle of separation of concerns. Which is to say, if I want to change how "the business" wants to service customers, I should not have to look through the entire system to figure out how to do this, and in particular, decisions business issues shouldn't be scattered willy-nilly through the code.

Now, this model served well for decades, and it is the classic 'client-server' model. Fast forward to cloud offerings, where web browsers are the user interface for a broad and physically distributed set of users, and one typically ends up having to add content distribution services, which aren't a part of the classic 3-tier architecture (and which need to be managed in their own right).

The concept generalizes when it comes to services, micro-services, how data and computation are distributed and so on. Whether or not something is a 'tier' largely comes down to whether or not the tier provides an interface and deployment model to services that are behind (or beneath) the tier. So a content distribution network would be a tier, but an authentication service would not be.

Now, go and read other descriptions of examples of N-tier architectures with this concept in mind, and you will begin to understand the issue. Other perspectives include vendor-based approaches (e.g. NGINX), content-aware load balancers, data isolation and security services (e.g. IBM Datapower), all of which may or may not add value to a given architecture, deployment, and use cases.

3

It's my understanding that N-Tier separates business logic, client access and data from each other using separate physical machines. The theory is that one of them can be updated independently of the others.

0
3

N-tier data applications are data applications that are separated into multiple tiers. Also called "distributed applications" and "multitier applications," n-tier applications separate processing into discrete tiers that are distributed between the client and the server. When you develop applications that access data, you should have a clear separation between the various tiers that make up the application.

And so on in http://msdn.microsoft.com/en-us/library/bb384398.aspx

3

When constructing the usual MCV (a 3-tier architecture) one can decide to implement the MCV with double-deck interfaces, such that one can in fact replace a particular tier without having to modify even one line of code.

We often see the benefits of this, for instance in scenarios where you want to be able to use more than one database (in which case you have a double-interface between the control and data-layers).

When you put it on the View-layer (presentation), then you can (hold on!!) replace the USER interface with another machine, thereby automate REAL input (!!!) - and you can thereby run tedious usability tests thousands of times without any user having to tap and re-tap and re-re-tap the same things over and over again.

Some describe such 3-tier architecture with 1 or 2 double-interfaces as 4-tier or 5-tier architecture, implicitly implying the double-interfaces.

Other cases include (but are not limited to) the fact that you - in case of semi-or-fully replicated database-systems would practically be able to consider one of the databases as the "master", and thereby you would have a tier comprising of the master and another comprising of the slave database.

Mobile example

Therefore, multi-tier - or N-tier - indeed has a few interpretations, whereas I would surely stick to the 3-tier + extra tiers comprising of thin interface-disks wedged in between to enable said tier-swaps, and in terms of testing (particularly used on mobile devices), you can now run user tests on the real software, by simulating a users tapping in ways which the control logic cannot distinguish from a real user tapping. This is almost paramount in simulating real user tests, in that you can record all inputs from the users OTA, and then re-use the same input when doing regression tests.

2

When we talk of Tiers, we generally talk of Physical Processes (having different memory space).

Thus, in case, Layers of an application are deployed in different processes, those different processes will be different tiers.

E.g, In a 3-tier application, business tier talks to Mainframes (separate process) and talks to Reporting Service (separate process), then that application would be 5 tier.

Hence, the generic name is n-tier.

2

from https://learn.microsoft.com/en-us/azure/architecture/guide/architecture-styles/n-tier

An N-tier architecture divides an application tires into logical tiresand physical tiers mainly and their are divide to sub parts. enter image description here

Layers are a way to separate responsibilities and manage dependencies. Each layer has a specific responsibility. A higher layer can use services in a lower layer, but not the other way around.

Tiers are physically separated, running on separate machines. A tier can call to another tier directly, or use asynchronous messaging (message queue). Although each layer might be hosted in its own tier, that's not required. Several layers might be hosted on the same tier. Physically separating the tiers improves scalability and resiliency, but also adds latency from the additional network communication.

A traditional three-tier application has a presentation tier, a middle tier, and a database tier. The middle tier is optional. More complex applications can have more than three tiers. The diagram above shows an application with two middle tiers, encapsulating different areas of functionality.

An N-tier application can have a closed layer architecture or an open layer architecture:

In a closed layer architecture, a layer can only call the next layer immediately down.
In an open layer architecture, a layer can call any of the layers below it.

A closed layer architecture limits the dependencies between layers. However, it might create unnecessary network traffic, if one layer simply passes requests along to the next layer.

1

An N-tier application is an application which has more than three components involved. What are those components?

  • Cache
  • Message queues for asynchronous behaviour
  • Load balancers
  • Search servers for searching through massive amounts of data
  • Components involved in processing massive amounts of data
  • Components running heterogeneous tech commonly known as web services etc.

All the social applications like Instagram, Facebook, large scale industry services like Uber, Airbnb, online massive multiplayer games like Pokemon Go, applications with fancy features are n-tier applications.

0

Martin Fowler demonstrating clearly:

Layering is one of the most common techniques that software designers use to break apart a complicated software system. You see it in machine architectures, where layers descend from a programming language with operating system calls into device drivers and CPU instruction sets, and into logic gates inside chips. Networking has FTP layered on top of TCP, which is on top of IP, which is on top of ethernet.

When thinking of a system in terms of layers, you imagine the principal subsystems in the software arranged in some form of layer cake, where each layer rests on a lower layer. In this scheme the higher layer uses various services defined by the lower layer, but the lower layer is unaware of the higher layer. Furthermore, each layer usually hides its lower layers from the layers above, so layer 4 uses the services of layer 3, which uses the services of layer 2, but layer 4 is unaware of layer 2. (Not all layering architectures are opaque like this, but most are—or rather most are mostly opaque.)

Breaking down a system into layers has a number of important benefits.

• You can understand a single layer as a coherent whole without knowing much about the other layers. You can understand how to build an FTP service on top of TCP without knowing the details of how ethernet works.

• You can substitute layers with alternative implementations of the same basic services. An FTP service can run without change over ethernet, PPP, or whatever a cable company uses.

• You minimize dependencies between layers. If the cable company changes its physical transmission system, providing they make IP work, we don’t have to alter our FTP service.

• Layers make good places for standardization. TCP and IP are standards because they define how their layers should operate.

• Once you have a layer built, you can use it for many higher-level services. Thus, TCP/IP is used by FTP, telnet, SSH, and HTTP. Otherwise, all of these higher-level protocols would have to write their own lower-level protocols. From the Library of Kyle Geoffrey Passarelli

Layering is an important technique, but there are downsides.

• Layers encapsulate some, but not all, things well. As a result you sometimes get cascading changes. The classic example of this in a layered enterprise application is adding a field that needs to display on the UI, must be in the database, and thus must be added to every layer in between.

• Extra layers can harm performance. At every layer things typically need to be transformed from one representation to another. However, the encapsulation of an underlying function often gives you efficiency gains that more than compensate. A layer that controls transactions can be optimized and will then make everything faster. But the hardest part of a layered architecture is deciding what layers to have and what the responsibility of each layer should be.

0

N-tier architecture is a multi-tier or multilayered client-server architecture that divides presentation, processing and data functions into logically and physically different tiers. More than three layers are uncommon in applications since they provide little benefits and might make the application slower, more difficult to manage, and more expensive to run.

Advantages of N-tier architecture

  1. Maintainability is high as maintaining, debugging, and deploying components in each layer is significantly easier.
  2. Re-usability is supported by N-tier architecture.
  3. Flexibility is enriched as it is possible to expand each tier according to the requirement.
  4. Scalability is massively enhanced when N-tier architecture is implemented.
  5. Security is increased in N-tier architecture because security is ensured in each tier with different methods.

For more details, please view the contents below-

-1

A tier is a group of computers having similar functionality and serving the same need. Tiers exist for security and scalability reasons. A typical modern web application is a 3-tiered one (and is also called "thin client"):

Tier 1 (Client tier). Code, running in your browser and in the browsers of all users of the system (millions of computers). Minimum to no business or application logic, just GUI logic.

Tier 2 (Application tier). Back-end code representing application and business logic running on the server (thousands of computers). All heavy lifting happens here.

Tier 3 (Persistence tier). Relational database nodes connected in a master/slave manner (tens of computers).

N-tier means that there can be additional groups of computers such as caches, proxies or other intermediaries.

3-tier architecture wasn't always the case. Twenty years a ago a 2-tier design (Client tier + Persistence tier, aka "thick client") was ubiquitous.

Important: the notion of "tiers" and "layers" is often conflated. Tiers are groups of devices that are always physically separated (by network or a process boundary) while "layer" is a purely software term.

Not the answer you're looking for? Browse other questions tagged or ask your own question.